From 1252106cd14f9577ba041a96a6130cc65d5f326c Mon Sep 17 00:00:00 2001 From: Alan Ly Date: Wed, 14 Oct 2020 13:37:33 +1100 Subject: [PATCH 1/8] Remove Apex test suite from create source package messages --- packages/sfpowerscripts-cli/messages/create_source_package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/sfpowerscripts-cli/messages/create_source_package.json b/packages/sfpowerscripts-cli/messages/create_source_package.json index 16d87de10..658290caf 100644 --- a/packages/sfpowerscripts-cli/messages/create_source_package.json +++ b/packages/sfpowerscripts-cli/messages/create_source_package.json @@ -3,7 +3,6 @@ "packageFlagDescription": "The name of the package", "versionNumberFlagDescription": "The format is major.minor.patch.buildnumber . This will override the build number mentioned in the sfdx-project.json, Try considering the use of Increment Version Number task before this task", "projectDirectoryFlagDescription": "The project directory should contain a sfdx-project.json for this command to succeed", - "apextestsuiteFlagDescription":"Apex Test Suite that needs to be associated with the source package, Source packages when deployed to production require each individual classes in the package to have more than 75% coverage, Hence this apex test task should cover all the classes", "destructiveManiFestFilePathFlagDescription":"Path to a destructiveChanges.xml, mentioning any metadata that need to be deleted before the contents in the source package need to be installed in the org", "artifactDirectoryFlagDescription": "The directory where the artifact is to be written", "diffCheckFlagDescription": "Only build when the package has changed", From 393aeeff797826877456181d82cdeb087c2b62af Mon Sep 17 00:00:00 2001 From: Alan Ly Date: Wed, 14 Oct 2020 13:39:58 +1100 Subject: [PATCH 2/8] Add Create & Install data package commands to CLI --- .../src/sfdxwrappers/CreateDataPackageImpl.ts | 78 +++++++++++ .../sfdxwrappers/InstallDataPackageImpl.ts | 47 +++++++ .../messages/create_data_package.json | 11 ++ .../messages/install_data_package.json | 10 ++ .../sfpowerscripts/CreateDataPackage.ts | 131 ++++++++++++++++++ .../sfpowerscripts/InstallDataPackage.ts | 108 +++++++++++++++ 6 files changed, 385 insertions(+) create mode 100644 packages/core/src/sfdxwrappers/CreateDataPackageImpl.ts create mode 100644 packages/core/src/sfdxwrappers/InstallDataPackageImpl.ts create mode 100644 packages/sfpowerscripts-cli/messages/create_data_package.json create mode 100644 packages/sfpowerscripts-cli/messages/install_data_package.json create mode 100644 packages/sfpowerscripts-cli/src/commands/sfpowerscripts/CreateDataPackage.ts create mode 100644 packages/sfpowerscripts-cli/src/commands/sfpowerscripts/InstallDataPackage.ts diff --git a/packages/core/src/sfdxwrappers/CreateDataPackageImpl.ts b/packages/core/src/sfdxwrappers/CreateDataPackageImpl.ts new file mode 100644 index 000000000..5aabe6b37 --- /dev/null +++ b/packages/core/src/sfdxwrappers/CreateDataPackageImpl.ts @@ -0,0 +1,78 @@ +import PackageMetadata from "../PackageMetadata"; +import SourcePackageGenerator from "../generators/SourcePackageGenerator"; +import ManifestHelpers from "../manifest/ManifestHelpers"; +import MDAPIPackageGenerator from "../generators/MDAPIPackageGenerator"; +import { isNullOrUndefined } from "util"; +import { EOL } from "os"; + +const fs = require("fs-extra"); +import path = require("path"); +import ApexTypeFetcher, { FileDescriptor } from "../parser/ApexTypeFetcher"; +const Table = require("cli-table"); + +export default class CreateDataPackageImpl { + public constructor( + private projectDirectory: string, + private sfdx_package: string, + private packageArtifactMetadata: PackageMetadata + ) {} + + public async exec(): Promise { + console.log( + "--------------Create Data Package---------------------------" + ); + console.log("Project Directory", this.projectDirectory); + console.log("sfdx_package", this.sfdx_package); + console.log("packageArtifactMetadata", this.packageArtifactMetadata); + + let startTime = Date.now(); + + //Get Package Descriptor + let packageDescriptor, packageDirectory: string; + if (this.sfdx_package != null) { + packageDescriptor = ManifestHelpers.getSFDXPackageDescriptor( + this.projectDirectory, + this.sfdx_package + ); + packageDirectory = packageDescriptor["path"]; + this.packageArtifactMetadata.preDeploymentSteps = packageDescriptor[ + "preDeploymentSteps" + ]?.split(","); + this.packageArtifactMetadata.postDeploymentSteps = packageDescriptor[ + "postDeploymentSteps" + ]?.split(","); + } + + + //Get Artifact Detailes + let sourcePackageArtifactDir = SourcePackageGenerator.generateSourcePackageArtifact( + this.projectDirectory, + this.sfdx_package, + packageDirectory + ); + + this.packageArtifactMetadata.sourceDir = sourcePackageArtifactDir; + + //Add Timestamps + let endTime = Date.now(); + let elapsedTime = endTime - startTime; + this.packageArtifactMetadata.creation_details = { + creation_time: elapsedTime, + timestamp: Date.now(), + }; + return this.packageArtifactMetadata; + } + + private printEmptyArtifactWarning() { + console.log( + "---------------------WARNING! Empty aritfact encountered-------------------------------" + ); + console.log( + "Either this folder is empty or the application of .forceignore results in an empty folder" + ); + console.log("Proceeding to create an empty artifact"); + console.log( + "---------------------------------------------------------------------------------------" + ); + } +} diff --git a/packages/core/src/sfdxwrappers/InstallDataPackageImpl.ts b/packages/core/src/sfdxwrappers/InstallDataPackageImpl.ts new file mode 100644 index 000000000..4a593d39d --- /dev/null +++ b/packages/core/src/sfdxwrappers/InstallDataPackageImpl.ts @@ -0,0 +1,47 @@ +import child_process = require("child_process"); +import { onExit } from "../utils/OnExit"; +import fs = require("fs"); +const path = require("path"); + +export default class InstallDataPackageImpl { + public constructor( + private targetusername: string, + private sourceDirectory: string, + private packageDirectory: string + ) {} + + public async exec(): Promise { + try { + let command = this.buildExecCommand(); + let child = child_process.exec( + command, + { cwd: path.resolve(this.sourceDirectory), encoding: "utf8" }, + (error, stdout, stderr) => { + if (error) { + throw error; + } + }); + + child.stdout.on("data", (data) => { + console.log(data.toString()); + }); + + await onExit(child); + } catch (err) { + let csvIssuesReportFilepath: string = path.join(this.sourceDirectory, this.packageDirectory, `CSVIssuesReport.csv`) + if (fs.existsSync(csvIssuesReportFilepath)) { + console.log(`CSV issues detected:`); + console.log(fs.readFileSync(csvIssuesReportFilepath, 'utf8')); + } + + throw err; + } + } + + private buildExecCommand(): string { + let command = `sfdx sfdmu:run --path ${this.packageDirectory} -s csvfile -u ${this.targetusername} --noprompt`; + + console.log(`Generated Command ${command}`); + return command; + } +} diff --git a/packages/sfpowerscripts-cli/messages/create_data_package.json b/packages/sfpowerscripts-cli/messages/create_data_package.json new file mode 100644 index 000000000..5cf94f87b --- /dev/null +++ b/packages/sfpowerscripts-cli/messages/create_data_package.json @@ -0,0 +1,11 @@ +{ + "commandDescription": "Creates a versioned artifact from a source directory containing SFDMU-based data (in csv format and export json). The artifact can be consumed by release pipelines, to deploy the data to orgs", + "packageFlagDescription": "The name of the package", + "versionNumberFlagDescription": "The format is major.minor.patch.buildnumber . This will override the build number mentioned in the sfdx-project.json, Try considering the use of Increment Version Number task before this task", + "projectDirectoryFlagDescription": "The project directory should contain a sfdx-project.json for this command to succeed", + "artifactDirectoryFlagDescription": "The directory where the artifact is to be written", + "diffCheckFlagDescription": "Only build when the package has changed", + "gitTagFlagDescription": "Tag the current commit ID with an annotated tag containing the package name and version - does not push tag", + "repoUrlFlagDescription": "Custom source repository URL to use in artifact metadata, overrides origin URL defined in git config", + "refNameFlagDescription": "Reference name to be prefixed to output variables" +} diff --git a/packages/sfpowerscripts-cli/messages/install_data_package.json b/packages/sfpowerscripts-cli/messages/install_data_package.json new file mode 100644 index 000000000..e1349d785 --- /dev/null +++ b/packages/sfpowerscripts-cli/messages/install_data_package.json @@ -0,0 +1,10 @@ +{ + "commandDescription": "Installs a SFDMU-based data package consisting of csvfiles and export.json to a target org", + "packageFlagDescription": "Name of the package to be installed", + "targetOrgFlagDescription": "Alias/User Name of the target environment", + "artifactDirectoryFlagDescription": "The directory where the artifact is located", + "skipOnMissingArtifactFlagDescription": "Skip package installation if the build artifact is missing. Enable this if artifacts are only being created for modified packages", + "skipIfAlreadyInstalled":"Skip the package installation if the package is already installed in the org", + "noPromptFlagDescription": "Skip prompt inputs or confirmation", + "subdirectoryFlagDescription": "Install specific subdirectory in the package. Useful when package consists of multiple discrete sub-packages" +} diff --git a/packages/sfpowerscripts-cli/src/commands/sfpowerscripts/CreateDataPackage.ts b/packages/sfpowerscripts-cli/src/commands/sfpowerscripts/CreateDataPackage.ts new file mode 100644 index 000000000..ed0f30cfb --- /dev/null +++ b/packages/sfpowerscripts-cli/src/commands/sfpowerscripts/CreateDataPackage.ts @@ -0,0 +1,131 @@ +import { flags } from '@salesforce/command'; +import SfpowerscriptsCommand from '../../SfpowerscriptsCommand'; +import { Messages } from '@salesforce/core'; +import PackageDiffImpl from '@dxatscale/sfpowerscripts.core/lib/package/PackageDiffImpl'; +import CreateDataPackageImpl from "@dxatscale/sfpowerscripts.core/lib/sfdxwrappers/CreateDataPackageImpl"; +import PackageMetadata from "@dxatscale/sfpowerscripts.core/lib/PackageMetadata"; +import ArtifactGenerator from "@dxatscale/sfpowerscripts.core/lib/generators/ArtifactGenerator"; +import { exec } from "shelljs"; +import fs = require("fs-extra"); + +Messages.importMessagesDirectory(__dirname); +const messages = Messages.loadMessages('@dxatscale/sfpowerscripts', 'create_data_package'); + +export default class CreateDataPackage extends SfpowerscriptsCommand { + + public static description = messages.getMessage('commandDescription'); + + public static examples = [ + `$ sfdx sfpowerscripts:CreateDataPackage -n mypackage -v `, + `$ sfdx sfpowerscripts:CreateDataPackage -n -v --diffcheck --gittag`, + `Output variable:`, + `sfpowerscripts_artifact_directory`, + `_sfpowerscripts_artifact_directory`, + `sfpowerscripts_package_version_number`, + `_sfpowerscripts_package_version_number` + ]; + + protected static requiresUsername = false; + protected static requiresDevhubUsername = false; + + protected static flagsConfig = { + package: flags.string({required: true, char: 'n', description: messages.getMessage('packageFlagDescription')}), + versionnumber: flags.string({required: true, char: 'v', description: messages.getMessage('versionNumberFlagDescription')}), + artifactdir: flags.directory({description: messages.getMessage('artifactDirectoryFlagDescription'), default: 'artifacts'}), + diffcheck: flags.boolean({description: messages.getMessage('diffCheckFlagDescription')}), + gittag: flags.boolean({description: messages.getMessage('gitTagFlagDescription')}), + repourl: flags.string({char: 'r', description: messages.getMessage('repoUrlFlagDescription')}), + refname: flags.string({description: messages.getMessage('refNameFlagDescription')}) + }; + + + public async execute(){ + try { + + const sfdx_package: string = this.flags.package; + const version_number: string = this.flags.versionnumber; + const artifactDirectory: string = this.flags.artifactdir; + const refname: string = this.flags.refname; + + + let runBuild: boolean; + if (this.flags.diffcheck) { + let packageDiffImpl = new PackageDiffImpl(sfdx_package, null); + + runBuild = await packageDiffImpl.exec(); + + if ( runBuild ) + console.log(`Detected changes to ${sfdx_package} package...proceeding\n`); + else + console.log(`No changes detected for ${sfdx_package} package...skipping\n`); + + } else runBuild = true; + + if (runBuild) { + let commit_id = exec('git log --pretty=format:%H -n 1', {silent:true}).stdout; + console.log(commit_id); + let repository_url: string; + if (this.flags.repourl == null) { + repository_url = exec('git config --get remote.origin.url', {silent:true}); + // Remove new line '\n' from end of url + repository_url = repository_url.slice(0,repository_url.length - 1); + } else repository_url = this.flags.repourl; + console.log(repository_url); + + + let packageMetadata:PackageMetadata = { + package_name: sfdx_package, + package_version_number: version_number, + sourceVersion: commit_id, + repository_url:repository_url, + package_type:"data", + apextestsuite: null + }; + fs.writeFileSync(`test.json`, JSON.stringify(packageMetadata, null, 4)); + //Convert to MDAPI + let createDataPackageImpl = new CreateDataPackageImpl( + null, + sfdx_package, + packageMetadata + ); + packageMetadata = await createDataPackageImpl.exec(); + + console.log(JSON.stringify(packageMetadata, function(key, val) { + if (key !== "payload") + return val; + })); + + + //Generate Artifact + let artifact = await ArtifactGenerator.generateArtifact(sfdx_package,process.cwd(),artifactDirectory,packageMetadata); + + console.log(`Created source package ${sfdx_package}_sfpowerscripts_artifact`); + + if (this.flags.gittag) { + exec(`git config --global user.email "sfpowerscripts@dxscale"`); + exec(`git config --global user.name "sfpowerscripts"`); + let tagname = `${sfdx_package}_v${version_number}`; + console.log(`Creating tag ${tagname}`); + exec(`git tag -a -m "${sfdx_package} Source Package ${version_number}" ${tagname} HEAD`, {silent:false}); + } + + console.log("\nOutput variables:"); + if (refname != null) { + fs.writeFileSync('.env', `${refname}_sfpowerscripts_artifact_directory=${artifact.artifactDirectory}\n`, {flag:'a'}); + console.log(`${refname}_sfpowerscripts_artifact_directory=${artifact.artifactDirectory}`); + fs.writeFileSync('.env', `${refname}_sfpowerscripts_package_version_number=${version_number}\n`, {flag:'a'}); + console.log(`${refname}_sfpowerscripts_package_version_number=${version_number}`); + } else { + fs.writeFileSync('.env', `sfpowerscripts_artifact_directory=${artifact.artifactSourceDirectory}\n`, {flag:'a'}); + console.log(`sfpowerscripts_artifact_directory=${artifact.artifactSourceDirectory}`); + fs.writeFileSync('.env', `sfpowerscripts_package_version_number=${version_number}\n`, {flag:'a'}); + console.log(`sfpowerscripts_package_version_number=${version_number}`); + } + } + } catch (err) { + console.log(err); + // Fail the task when an error occurs + process.exit(1); + } + } +} diff --git a/packages/sfpowerscripts-cli/src/commands/sfpowerscripts/InstallDataPackage.ts b/packages/sfpowerscripts-cli/src/commands/sfpowerscripts/InstallDataPackage.ts new file mode 100644 index 000000000..cc49c50a0 --- /dev/null +++ b/packages/sfpowerscripts-cli/src/commands/sfpowerscripts/InstallDataPackage.ts @@ -0,0 +1,108 @@ +import { flags } from '@salesforce/command'; +import SfpowerscriptsCommand from '../../SfpowerscriptsCommand'; +import InstallDataPackageImpl from '@dxatscale/sfpowerscripts.core/lib/sfdxwrappers/InstallDataPackageImpl' +import ManifestHelpers from '@dxatscale/sfpowerscripts.core/lib/manifest/ManifestHelpers'; +import { Messages } from '@salesforce/core'; +const fs = require("fs"); +const path = require("path"); + +// Initialize Messages with the current plugin directory +Messages.importMessagesDirectory(__dirname); + +// Load the specific messages for this file. Messages from @salesforce/command, @salesforce/core, +// or any library that is using the messages framework can also be loaded this way. +const messages = Messages.loadMessages('@dxatscale/sfpowerscripts', 'install_data_package'); + +export default class InstallDataPackage extends SfpowerscriptsCommand { + + public static description = messages.getMessage('commandDescription'); + + public static examples = [ + `$ sfdx sfpowerscripts:InstallDataPackage ` + ]; + + + protected static flagsConfig = { + package: flags.string({char: 'n', description: messages.getMessage('packageFlagDescription')}), + targetorg: flags.string({char: 'u', description: messages.getMessage('targetOrgFlagDescription')}), + artifactdir: flags.directory({description: messages.getMessage('artifactDirectoryFlagDescription'), default: 'artifacts'}), + skipifalreadyinstalled: flags.boolean({char: "f",description: messages.getMessage("skipIfAlreadyInstalled")}), + skiponmissingartifact: flags.boolean({description: messages.getMessage('skipOnMissingArtifactFlagDescription'), dependsOn: ['packageinstalledfrom']}), + noprompt: flags.boolean({description: messages.getMessage('noPromptFlagDescription')}), + subdirectory: flags.directory({description: messages.getMessage('subdirectoryFlagDescription')}), + }; + + protected static requiresUsername = false; + protected static requiresDevhubUsername = false; + + public async execute(){ + try { + + const targetOrg: string = this.flags.targetorg; + const sfdx_package: string = this.flags.package; + let skip_on_missing_artifact: boolean = this.flags.skiponmissingartifact; + + const artifact_directory: string = this.flags.artifactdir; + const skipIfAlreadyInstalled = this.flags.skipifalreadyinstalled; + const subdirectory: string = this.flags.subdirectory; + + + let artifactMetadataFilepath = path.join( + artifact_directory, + `${sfdx_package}_sfpowerscripts_artifact`, + `artifact_metadata.json` + ); + + console.log(`Checking for ${sfdx_package} Build Artifact at path ${artifactMetadataFilepath}`); + + if (!fs.existsSync(artifactMetadataFilepath) && !skip_on_missing_artifact) { + throw new Error( + `Artifact not found at ${artifactMetadataFilepath}.. Please check the inputs` + ); + } else if(!fs.existsSync(artifactMetadataFilepath) && skip_on_missing_artifact) { + console.log(`Skipping task as artifact is missing, and 'SkipOnMissingArtifact' ${skip_on_missing_artifact}`); + process.exit(0); + } + + let packageMetadata = JSON.parse(fs + .readFileSync(artifactMetadataFilepath) + .toString()); + + console.log("Package Metadata:"); + console.log(packageMetadata); + + let sourceDirectory: string = path.join( + artifact_directory, + `${sfdx_package}_sfpowerscripts_artifact`, + `source` + ) + + let packageDescriptor = ManifestHelpers.getSFDXPackageDescriptor(sourceDirectory, sfdx_package); + + let packageDirectory: string; + if (subdirectory) { + packageDirectory = path.join( + packageDescriptor["path"], + subdirectory + ); + } else { + packageDirectory = path.join( + packageDescriptor["path"] + ) + } + + + let installDataPackageImpl: InstallDataPackageImpl = new InstallDataPackageImpl( + targetOrg, + sourceDirectory, + packageDirectory + ) + + await installDataPackageImpl.exec(); + + } catch(err) { + console.log(err); + process.exit(1); + } + } +} From bc4090668f097bf8a452ebb7b63b6dd0093a276e Mon Sep 17 00:00:00 2001 From: Alan Ly Date: Wed, 14 Oct 2020 16:19:12 +1100 Subject: [PATCH 3/8] Add CreateDataPackage to Azp Output stderr in InstallDataPackageImpl --- lerna.json | 1 + .../CreateDataPackage.ts | 99 ++++ .../BuildTasks/CreateDataPackageTask/icon.png | Bin 0 -> 2637 bytes .../CreateDataPackageTask/package-lock.json | 485 ++++++++++++++++++ .../CreateDataPackageTask/package.json | 15 + .../CreateDataPackageTask/task.json | 79 +++ .../CreateDataPackageTask/tsconfig.json | 11 + packages/azpipelines/vss-extension.json | 13 + .../src/sfdxwrappers/CreateDataPackageImpl.ts | 3 + .../sfdxwrappers/InstallDataPackageImpl.ts | 16 +- 10 files changed, 714 insertions(+), 8 deletions(-) create mode 100644 packages/azpipelines/BuildTasks/CreateDataPackageTask/CreateDataPackage.ts create mode 100644 packages/azpipelines/BuildTasks/CreateDataPackageTask/icon.png create mode 100644 packages/azpipelines/BuildTasks/CreateDataPackageTask/package-lock.json create mode 100644 packages/azpipelines/BuildTasks/CreateDataPackageTask/package.json create mode 100644 packages/azpipelines/BuildTasks/CreateDataPackageTask/task.json create mode 100644 packages/azpipelines/BuildTasks/CreateDataPackageTask/tsconfig.json diff --git a/lerna.json b/lerna.json index b65ec6322..b35c1b333 100644 --- a/lerna.json +++ b/lerna.json @@ -6,6 +6,7 @@ "packages/azpipelines/BuildTasks/AnalyzeWithPMDTask", "packages/azpipelines/BuildTasks/AuthenticateOrgTaskCurrent", "packages/azpipelines/BuildTasks/CheckoutProjectFromArtifactTask", + "packages/azpipelines/BuildTasks/CreateDataPackageTask", "packages/azpipelines/BuildTasks/CreateDeltaPackageTask", "packages/azpipelines/BuildTasks/CreateSourcePackageTask", "packages/azpipelines/BuildTasks/CreateUnlockedPackageTask", diff --git a/packages/azpipelines/BuildTasks/CreateDataPackageTask/CreateDataPackage.ts b/packages/azpipelines/BuildTasks/CreateDataPackageTask/CreateDataPackage.ts new file mode 100644 index 000000000..e7f865e68 --- /dev/null +++ b/packages/azpipelines/BuildTasks/CreateDataPackageTask/CreateDataPackage.ts @@ -0,0 +1,99 @@ +import tl = require("azure-pipelines-task-lib/task"); +import PackageDiffImpl from "@dxatscale/sfpowerscripts.core/lib/package/PackageDiffImpl"; +import CreateDataPackageImpl from "@dxatscale/sfpowerscripts.core/lib/sfdxwrappers/CreateDataPackageImpl"; +import PackageMetadata from "@dxatscale/sfpowerscripts.core/lib/PackageMetadata"; +import ArtifactGenerator from "@dxatscale/sfpowerscripts.core/lib/generators/ArtifactGenerator" + + + +async function run() { + try { + let sfdx_package: string = tl.getInput("package", true); + let version_number: string = tl.getInput("version_number", false); + let isDiffCheck: boolean = tl.getBoolInput("isDiffCheck", false); + let isGitTag: boolean = tl.getBoolInput("isGitTag", false); + let projectDirectory: string = tl.getInput("project_directory", false); + let commitId = tl.getVariable("build.sourceVersion"); + let repositoryUrl = tl.getVariable("build.repository.uri"); + + let isRunBuild: boolean; + if (isDiffCheck) { + let packageDiffImpl = new PackageDiffImpl( + sfdx_package, + projectDirectory + ); + + isRunBuild = await packageDiffImpl.exec(); + + if (isRunBuild) + console.log( + `Detected changes to ${sfdx_package} package...proceeding\n` + ); + else + console.log( + `No changes detected for ${sfdx_package} package...skipping\n` + ); + } else isRunBuild = true; + + if (isRunBuild) { + //Create Metadata Artifact + let packageMetadata:PackageMetadata = { + package_name: sfdx_package, + package_version_number: version_number, + sourceVersion: commitId, + repository_url: repositoryUrl, + apextestsuite:null + }; + + + let createDataPackageImpl: CreateDataPackageImpl = new CreateDataPackageImpl( + projectDirectory, + sfdx_package, + packageMetadata + ); + packageMetadata = await createDataPackageImpl.exec(); + + + console.log("##[command]Package Metadata:"+JSON.stringify(packageMetadata)); + + + let artifact= await ArtifactGenerator.generateArtifact(sfdx_package,projectDirectory,tl.getVariable("agent.tempDirectory"),packageMetadata); + + tl.uploadArtifact(`${sfdx_package}_sfpowerscripts_artifact`, artifact.artifactDirectory,`${sfdx_package}_sfpowerscripts_artifact`); + + + + + tl.setVariable("sfpowerscripts_package_version_number", version_number); + tl.setVariable( + "sfpowerscripts_source_package_metadata_path", + artifact.artifactMetadataFilePath + ); + tl.setVariable( + "sfpowerscripts_source_package_path", + artifact.artifactSourceDirectory + ); + + + //Create Git Tag + if (isGitTag) { + let tagname: string = `${sfdx_package}_v${version_number}`; + tl.setVariable(`${sfdx_package}_sfpowerscripts_git_tag`, tagname); + if (projectDirectory == null) + tl.setVariable( + `${sfdx_package}_sfpowerscripts_project_directory_path`, + tl.getVariable("Build.Repository.LocalPath") + ); + else + tl.setVariable( + `${sfdx_package}_sfpowerscripts_project_directory_path`, + projectDirectory + ); + } + } + } catch (err) { + tl.setResult(tl.TaskResult.Failed, err.message); + } +} + +run(); diff --git a/packages/azpipelines/BuildTasks/CreateDataPackageTask/icon.png b/packages/azpipelines/BuildTasks/CreateDataPackageTask/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..36b0bcad4f52d1b018ed0d3cdaee1be70addd1fb GIT binary patch literal 2637 zcmc&$XIB&07EK5UBuZ358^MeqEm$ZbMQVt2LPrQ4l%|N36p#|C5(O0LMVf#kO+X|> zr6zy|MPWb$1EB?w-lW51-un%2y}Q=AXPvV@-Mh}&dna0;4Nidn00RJk6Gnz8D|ROS z8$8F@cZZfcot=QeRt88w^%v1OcERbbYo-eT)TTi8-MQE`?>$3@U;u!R`fmW!<@nC9 zdlN<|T^oYSVm`zt*;TZw*DFi0@d@3DrPV~eDfPWF{!N0DV|zEsr21Kwp-iTeVy66- zNpY4tIEnh$-bk;k=VF<|olBED1q~eota|3m@1@Y@8T^trFasq# zboymD$oerL%agNJR06;f2FiEw5Y_YnJqjFd$)^Cp|3m2YkMjs^ZC99}AgQm<%JLn~ z{~HB++p;Ax0-L6AQpfhZghU7F(W835!Ajof8?){0?Uh^*L3=JPu3yG3HflhoXV~u7 zs0pN=UR6(zDOUQdO}4n())K>G_>C{(cR(S596ZC9A|7*-IfFu>_EU4^I*cs;lD2W) zALZy)bP3;CyG}zCP^qY=IXSO9Y@scJIyyQ;@J_~DfBB>QYxr081MLBOz#Nr;YGkwb z_iAU4k+=Q`yM`4LhW&vbNthub9d7AcxGQf^AJLEKcsch6$(<^R~*#)vE$D8ckeEN}skd zslp*6BV$oS3QYIvo(l~PMP40<3?%pFssx})^pjBb_E|ptWl19q{v&pA2??n>_bv@@ zN=izGn7an8PFxRq`=@J8NmI}?se!QSQM2f;x-&kPQ*K@mrm+-cX=xeaa$Qt|@O2W~ zjKeYQAy4x1Oj-D^g}TVAxzzQU-horgHZ?BJ@fz0UXfc7c9m{Kkjx{Wjw~b}V)7kYNurJ*sr5r*@^lWs}809wtUcMFb2cCrj}bI3C;g%2w`N zRVK+dW`U?T^xD1Sve#-r9t^-Rz(7*EKBx)Z-&)!vI6aV)le2C?LX%}VelLzlv%ch4 zc!aBkuDt-ywVmQ);+;Ra!5X9~Q=Dqk0ed;1@FcCacJd~inQD7q0B zxl<;V5D?XggDl^<@4uKW0?z9z0Wmi%(htH6VYfAiDYBQZ^QpOT0qW@P|0bVaJ%nC zVi@UGl~Yq+{*t(+=D~yYD4dd4kA*j8ur(T_`Fv7Nh@ZdYc_p{w1)YwB6STTpbeqaG z*@D~7W*^oF^U^Zf&kVNQPK3!|i=6@6s`9lsA{O-WPBo^%xKtJD%BK~ItN_So_F5-z zNX||LM$;sG?t0z2^%ra=TAhS`18z-D%&Qgz4nkYGxVeu8dcHN z>(r*#>+lOhwKlN^*XyH>4wpob(`|)NMA6pr7~cF(S!gA7WxRvYq<}ye|0D;-wl{M| z2&yY3p5f8quC1-reuIw~cX}UrFgzKUInQ|4sNR1qVs~Sekn#zKE2`qr>CL-j@ncVH zlm$xTPSY-I) zx=hA9Jc9a6!L!qXPUVHeeS`qN8Eud!v}ogTpkQv{(fIc2B!VU~q%I2^)X9jwa`k9! z+GK0WG>WU{^ubB{#n_}W`Eobv!&BlK8czA+8loz4Lxn<%*NJTo|1$YE4#LLlQ}b)? zhw0i5wF@Dlazrv&^;?l1ci;q-H+@1wJ_14?L~wx6=LuEGpdDb8{)0V)p- zq-R{5Se@*;azacZp5XFG@FJD{#*bs2~|?mzGPOfJii&Z)Zr; z>1uB!d!L3Yd42CCCMIUUhyo%az6}9mqnI~7Pi<{%P+jV{1;a=`zgNm(8$MggRu8Aj zOG_P$jErEN$!;s<=zPB_*Ouq)LtuRj2iP-RX@6qEW7i+udWu68`wR9#ID92^on?t( z>qt7AyWB;C<3S)$RXjwfuZfqJH*K&`7c?9VfuEiG5Vl!-d*vLH{?kCK&zar>+}C@+ zXDJMa2QDC`f|WEouxF_j7>r-i8I>>j$4+VmP4VQPfx%F|Y#PKDfZ+2m2m~T~p-Pz1 zVWe8jN8}Y+14L_dQ3sfC~RH1nOyst zLxLcDYoy*AYPQhY33Xc>Zn&a+QA=y|1LynTnJ-hGimbzfJ>R&KAJS&2K(dO|!wb%o zG*VH)XO&2(-D&suZ}r~2K6@fCl}i>6+Qy=JYprG{hH5?EUI5iRIl{VK9{PIj{Q0;b zUQ^Z9(F0joSy%?gz1&@NzPjZfK`-bUo^^?ksTHGVQVw-_Wu6WW4rwlt)2q=S?#k5E z)8GzuqVnxQ3(?-xX_e9>QMJ^*o1x~p=5B2~I4S(OdB7lBpy#4sOm&CG!gb3y;P-&e zhB~B)`+~ykdC_x#04D9@&nk~EdKi)2q{D}b7S0D-^5$F0@xN1V00agsz$oS`~zoP-RJ-S literal 0 HcmV?d00001 diff --git a/packages/azpipelines/BuildTasks/CreateDataPackageTask/package-lock.json b/packages/azpipelines/BuildTasks/CreateDataPackageTask/package-lock.json new file mode 100644 index 000000000..a88d68c3f --- /dev/null +++ b/packages/azpipelines/BuildTasks/CreateDataPackageTask/package-lock.json @@ -0,0 +1,485 @@ +{ + "name": "sfpowerscripts-createdatapackage-task", + "version": "1.0.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "@dxatscale/sfpowerscripts.core": { + "version": "2.1.6", + "resolved": "https://registry.npmjs.org/@dxatscale/sfpowerscripts.core/-/sfpowerscripts.core-2.1.6.tgz", + "integrity": "sha512-o2q+nRmk2ON1k8VCk85/UTosOPpz8kOUyQmRp2mHeGAfG/P9FHGl+McbrUcioHxseCquP0snE/ud2q7xd5weIw==", + "requires": { + "antlr4ts": "^0.5.0-alpha.3", + "apex-parser": "^2.5.0", + "async-retry": "^1.3.1", + "cli-table": "^0.3.1", + "fs-extra": "^8.1.0", + "glob": "^7.1.6", + "ignore": "^5.1.6", + "rimraf": "^3.0.2", + "shelljs": "^0.8.4", + "simple-git": "2.0.0", + "unzip-stream": "0.3.0", + "xml2js": "^0.4.23" + }, + "dependencies": { + "shelljs": { + "version": "0.8.4", + "resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.8.4.tgz", + "integrity": "sha512-7gk3UZ9kOfPLIAbslLzyWeGiEqx9e3rxwZM0KE6EL8GlGwjym9Mrlx5/p33bWTu9YG6vcS4MBxYZDHYr5lr8BQ==", + "requires": { + "glob": "^7.0.0", + "interpret": "^1.0.0", + "rechoir": "^0.6.2" + } + } + } + }, + "@kwsites/exec-p": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/@kwsites/exec-p/-/exec-p-0.4.0.tgz", + "integrity": "sha512-44DWNv5gDR9EwrCTVQ4ZC99yPqVS0VCWrYIBl45qNR8XQy+4lbl0IQG8kBDf6NHwj4Ib4c2z1Fq1IUJOCbkZcw==" + }, + "antlr4ts": { + "version": "0.5.0-alpha.3", + "resolved": "https://registry.npmjs.org/antlr4ts/-/antlr4ts-0.5.0-alpha.3.tgz", + "integrity": "sha512-La89tKkGcHFIVuruv4Bm1esc3zLmES2NOTEwwNS1pudz+zx/0FNqQeUu9p48i9/QHKPVqjN87LB+q3buTg7oDQ==" + }, + "apex-parser": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/apex-parser/-/apex-parser-2.5.0.tgz", + "integrity": "sha512-rXZyVgbUSmotjnPTVlJSP8fhIiRwFT6373X6rEwedSC9QorZSV+SqHKy+lhzJCVHUpLIzGXjGRCdtYZLlwkf4Q==", + "requires": { + "antlr4ts": "^0.5.0-alpha.3" + } + }, + "asap": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz", + "integrity": "sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY=" + }, + "async-retry": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/async-retry/-/async-retry-1.3.1.tgz", + "integrity": "sha512-aiieFW/7h3hY0Bq5d+ktDBejxuwR78vRu9hDUdR8rNhSaQ29VzPL4AoIRG7D/c7tdenwOcKvgPM6tIxB3cB6HA==", + "requires": { + "retry": "0.12.0" + } + }, + "azure-pipelines-task-lib": { + "version": "2.11.3", + "resolved": "https://registry.npmjs.org/azure-pipelines-task-lib/-/azure-pipelines-task-lib-2.11.3.tgz", + "integrity": "sha512-gXops6Npkloh7AKPIvptx0KY1kdf1yd+BFdp/ksnbyW7CS3uXzBQXU1Dermr7A895TrOd02PI6hmsL8cBlePNA==", + "requires": { + "minimatch": "3.0.4", + "mockery": "^1.7.0", + "q": "^1.1.2", + "semver": "^5.1.0", + "shelljs": "^0.3.0", + "sync-request": "3.0.1", + "uuid": "^3.0.1" + } + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" + }, + "binary": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/binary/-/binary-0.3.0.tgz", + "integrity": "sha1-n2BVO8XOjDOG87VTz/R0Yq3sqnk=", + "requires": { + "buffers": "~0.1.1", + "chainsaw": "~0.1.0" + } + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "buffer-from": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", + "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==" + }, + "buffers": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/buffers/-/buffers-0.1.1.tgz", + "integrity": "sha1-skV5w77U1tOWru5tmorn9Ugqt7s=" + }, + "caseless": { + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.11.0.tgz", + "integrity": "sha1-cVuW6phBWTzDMGeSP17GDr2k99c=" + }, + "chainsaw": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/chainsaw/-/chainsaw-0.1.0.tgz", + "integrity": "sha1-XqtQsor+WAdNDVgpE4iCi15fvJg=", + "requires": { + "traverse": ">=0.3.0 <0.4" + } + }, + "cli-table": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/cli-table/-/cli-table-0.3.1.tgz", + "integrity": "sha1-9TsFJmqLGguTSz0IIebi3FkUriM=", + "requires": { + "colors": "1.0.3" + } + }, + "colors": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/colors/-/colors-1.0.3.tgz", + "integrity": "sha1-BDP0TYCWgP3rYO0mDxsMJi6CpAs=" + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" + }, + "concat-stream": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", + "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", + "requires": { + "buffer-from": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^2.2.2", + "typedarray": "^0.0.6" + } + }, + "core-util-is": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" + }, + "debug": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.2.0.tgz", + "integrity": "sha512-IX2ncY78vDTjZMFUdmsvIRFY2Cf4FnD0wRs+nQwJU8Lu99/tPFdb0VybiiMTPe3I6rQmwsqQqRBvxU+bZ/I8sg==", + "requires": { + "ms": "2.1.2" + } + }, + "fs-extra": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz", + "integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==", + "requires": { + "graceful-fs": "^4.2.0", + "jsonfile": "^4.0.0", + "universalify": "^0.1.0" + } + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" + }, + "glob": { + "version": "7.1.6", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", + "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "graceful-fs": { + "version": "4.2.4", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.4.tgz", + "integrity": "sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw==" + }, + "http-basic": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/http-basic/-/http-basic-2.5.1.tgz", + "integrity": "sha1-jORHvbW2xXf4pj4/p4BW7Eu02/s=", + "requires": { + "caseless": "~0.11.0", + "concat-stream": "^1.4.6", + "http-response-object": "^1.0.0" + } + }, + "http-response-object": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/http-response-object/-/http-response-object-1.1.0.tgz", + "integrity": "sha1-p8TnWq6C87tJBOT0P2FWc7TVGMM=" + }, + "ignore": { + "version": "5.1.8", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.1.8.tgz", + "integrity": "sha512-BMpfD7PpiETpBl/A6S498BaIJ6Y/ABT93ETbby2fP00v4EbvPBXWEoaR1UBPKs3iR53pJY7EtZk5KACI57i1Uw==" + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + }, + "interpret": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/interpret/-/interpret-1.4.0.tgz", + "integrity": "sha512-agE4QfB2Lkp9uICn7BAqoscw4SZP9kTE2hxiFI3jBPmXJfdqiahTbUuKGsMoN2GtqL9AxhYioAcVvgsb1HvRbA==" + }, + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" + }, + "jsonfile": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", + "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", + "requires": { + "graceful-fs": "^4.1.6" + } + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "minimist": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", + "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==" + }, + "mkdirp": { + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", + "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", + "requires": { + "minimist": "^1.2.5" + } + }, + "mockery": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/mockery/-/mockery-1.7.0.tgz", + "integrity": "sha1-9O3g2HUMHJcnwnLqLGBiniyaHE8=" + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "requires": { + "wrappy": "1" + } + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" + }, + "path-parse": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", + "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==" + }, + "process-nextick-args": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", + "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==" + }, + "promise": { + "version": "7.3.1", + "resolved": "https://registry.npmjs.org/promise/-/promise-7.3.1.tgz", + "integrity": "sha512-nolQXZ/4L+bP/UGlkfaIujX9BKxGwmQ9OT4mOt5yvy8iK1h3wqTEJCijzGANTCCl9nWjY41juyAn2K3Q1hLLTg==", + "requires": { + "asap": "~2.0.3" + } + }, + "q": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/q/-/q-1.5.1.tgz", + "integrity": "sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc=" + }, + "qs": { + "version": "6.9.4", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.9.4.tgz", + "integrity": "sha512-A1kFqHekCTM7cz0udomYUoYNWjBebHm/5wzU/XqrBRBNWectVH0QIiN+NEcZ0Dte5hvzHwbr8+XQmguPhJ6WdQ==" + }, + "readable-stream": { + "version": "2.3.7", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", + "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "rechoir": { + "version": "0.6.2", + "resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.6.2.tgz", + "integrity": "sha1-hSBLVNuoLVdC4oyWdW70OvUOM4Q=", + "requires": { + "resolve": "^1.1.6" + } + }, + "resolve": { + "version": "1.17.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.17.0.tgz", + "integrity": "sha512-ic+7JYiV8Vi2yzQGFWOkiZD5Z9z7O2Zhm9XMaTxdJExKasieFCr+yXZ/WmXsckHiKl12ar0y6XiXDx3m4RHn1w==", + "requires": { + "path-parse": "^1.0.6" + } + }, + "retry": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/retry/-/retry-0.12.0.tgz", + "integrity": "sha1-G0KmJmoh8HQh0bC1S33BZ7AcATs=" + }, + "rimraf": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", + "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", + "requires": { + "glob": "^7.1.3" + } + }, + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + }, + "sax": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz", + "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==" + }, + "semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==" + }, + "shelljs": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.3.0.tgz", + "integrity": "sha1-NZbmMHp4FUT1kfN9phg2DzHbV7E=" + }, + "simple-git": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/simple-git/-/simple-git-2.0.0.tgz", + "integrity": "sha512-R7P9WfnHmwnUlRowXGT93FOhhGvRQWWGhgH6Nf3lCXOv4SjtAuK25Tfhf4VFYueQ11r4WDMUVLXtKFGWPwLehg==", + "requires": { + "@kwsites/exec-p": "^0.4.0", + "debug": "^4.0.1" + } + }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "requires": { + "safe-buffer": "~5.1.0" + } + }, + "sync-request": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/sync-request/-/sync-request-3.0.1.tgz", + "integrity": "sha1-yqEjWq+Im6UBB2oYNMQ2gwqC+3M=", + "requires": { + "concat-stream": "^1.4.7", + "http-response-object": "^1.0.1", + "then-request": "^2.0.1" + } + }, + "then-request": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/then-request/-/then-request-2.2.0.tgz", + "integrity": "sha1-ZnizL6DKIY/laZgbvYhxtZQGDYE=", + "requires": { + "caseless": "~0.11.0", + "concat-stream": "^1.4.7", + "http-basic": "^2.5.1", + "http-response-object": "^1.1.0", + "promise": "^7.1.1", + "qs": "^6.1.0" + } + }, + "traverse": { + "version": "0.3.9", + "resolved": "https://registry.npmjs.org/traverse/-/traverse-0.3.9.tgz", + "integrity": "sha1-cXuPIgzAu3tE5AUUwisui7xw2Lk=" + }, + "typedarray": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", + "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=" + }, + "universalify": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", + "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==" + }, + "unzip-stream": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/unzip-stream/-/unzip-stream-0.3.0.tgz", + "integrity": "sha512-NG1h/MdGIX3HzyqMjyj1laBCmlPYhcO4xEy7gEqqzGiSLw7XqDQCnY4nYSn5XSaH8mQ6TFkaujrO8d/PIZN85A==", + "requires": { + "binary": "^0.3.0", + "mkdirp": "^0.5.1" + } + }, + "util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" + }, + "uuid": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", + "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==" + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" + }, + "xml2js": { + "version": "0.4.23", + "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.23.tgz", + "integrity": "sha512-ySPiMjM0+pLDftHgXY4By0uswI3SPKLDw/i3UXbnO8M/p28zqexCUoPmQFrYD+/1BzhGJSs2i1ERWKJAtiLrug==", + "requires": { + "sax": ">=0.6.0", + "xmlbuilder": "~11.0.0" + } + }, + "xmlbuilder": { + "version": "11.0.1", + "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-11.0.1.tgz", + "integrity": "sha512-fDlsI/kFEx7gLvbecc0/ohLG50fugQp8ryHzMTuW9vSa1GJ0XYWKnhsUx7oie3G98+r56aTQIUB4kht42R3JvA==" + } + } +} diff --git a/packages/azpipelines/BuildTasks/CreateDataPackageTask/package.json b/packages/azpipelines/BuildTasks/CreateDataPackageTask/package.json new file mode 100644 index 000000000..bb163a216 --- /dev/null +++ b/packages/azpipelines/BuildTasks/CreateDataPackageTask/package.json @@ -0,0 +1,15 @@ +{ + "name": "sfpowerscripts-createdatapackage-task", + "description": "sfpowerscripts-createdatapackage-task", + "version": "1.0.0", + "private": true, + "scripts": { + "version": "node ../../versionupdate.js && git add task.json", + "build": "rimraf lib && tsc -b" + }, + "license": "MIT", + "dependencies": { + "@dxatscale/sfpowerscripts.core": "^2.1.6", + "azure-pipelines-task-lib": "^2.11.3" + } +} diff --git a/packages/azpipelines/BuildTasks/CreateDataPackageTask/task.json b/packages/azpipelines/BuildTasks/CreateDataPackageTask/task.json new file mode 100644 index 000000000..6d6c8d74d --- /dev/null +++ b/packages/azpipelines/BuildTasks/CreateDataPackageTask/task.json @@ -0,0 +1,79 @@ +{ + "id": "f33c11ff-5ea2-4502-be51-31d7aa27de6e", + "name": "sfpowerscripts-createdatapackage-task", + "friendlyName": "Create a data package", + "description": "Creates a versioned artifact from a source directory containing SFDMU-based data (in csv format and export json). The artifact can be consumed by release pipelines, to deploy the data to orgs", + "helpMarkDown": "", + "category": "Build", + "author": "{{taskauthor}}", + "version": { + "Major": 1, + "Minor": 0, + "Patch": 0 + }, + "runsOn": [ + "Agent" + ], + "instanceNameFormat": "Creates a new version of Data Package for $(package)", + "inputs": [ + { + "name": "package", + "type": "string", + "label": "Name of the package, as mentioned in sfdx-project.json", + "defaultValue": "", + "required": true, + "helpMarkDown": "The name of the package, that is mentioned in sfdx-project.json" + }, + { + "name": "version_number", + "type": "string", + "label": "The version number of the package to be created", + "defaultValue": "", + "required": false, + "helpMarkDown": "The format is major.minor.patch.buildnumber . This will override the build number mentioned in the sfdx-project.json, Try considering the use of Increment Version Number task before this task" + }, + { + "name": "isDiffCheck", + "type": "boolean", + "label": "Only run task if package has changed", + "defaultValue": false, + "required": false, + "helpMarkDown": "Check this box to enable package creation only when the package has been modified" + }, + { + "name": "isGitTag", + "type": "boolean", + "label": "Tag latest commit ID with package name and version", + "defaultValue": false, + "required": false, + "helpMarkDown": "Tags the latest commit with the package name and version, upon successful build" + }, + { + "name": "project_directory", + "type": "string", + "label": "Project Directory", + "defaultValue": "", + "required": false, + "helpMarkDown": "The project directory should contain a sfdx-project.json for this command to succeed" + } + ], + "OutputVariables": [ + { + "name": "sfpowerscripts_package_version_number", + "description": "The version number of the package that was created" + }, + { + "name": "sfpowerscripts_source_package_metadata_path", + "description": "The path to the metadata artifact created by this task" + }, + { + "name": "sfpowerscripts_source_package_path", + "description": "The path to source artifact built by this task" + } +], + "execution": { + "Node": { + "target": "lib/CreateDataPackage.js" + } + } +} diff --git a/packages/azpipelines/BuildTasks/CreateDataPackageTask/tsconfig.json b/packages/azpipelines/BuildTasks/CreateDataPackageTask/tsconfig.json new file mode 100644 index 000000000..bb873706c --- /dev/null +++ b/packages/azpipelines/BuildTasks/CreateDataPackageTask/tsconfig.json @@ -0,0 +1,11 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "outDir": "./lib", + "sourceRoot": "./", + "composite": false + }, + "files": [ + "CreateDataPackage.ts" + ] +} diff --git a/packages/azpipelines/vss-extension.json b/packages/azpipelines/vss-extension.json index 24121491c..d6963623f 100644 --- a/packages/azpipelines/vss-extension.json +++ b/packages/azpipelines/vss-extension.json @@ -125,6 +125,9 @@ { "path": "BuildTasks/InstallSourcePackageTask" }, + { + "path": "BuildTasks/CreateDataPackageTask" + }, { "path": "BuildTasks/CreateSourcePackageTask" }, @@ -404,6 +407,16 @@ "name": "BuildTasks/InstallSourcePackageTask" } }, + { + "id": "sfpowerscripts-createdatapackage-task", + "type": "ms.vss-distributed-task.task", + "targets": [ + "ms.vss-distributed-task.tasks" + ], + "properties": { + "name": "BuildTasks/CreateDataPackageTask" + } + }, { "id": "sfpwowerscripts-createsourcepackage-task", "type": "ms.vss-distributed-task.task", diff --git a/packages/core/src/sfdxwrappers/CreateDataPackageImpl.ts b/packages/core/src/sfdxwrappers/CreateDataPackageImpl.ts index 5aabe6b37..decdf58e3 100644 --- a/packages/core/src/sfdxwrappers/CreateDataPackageImpl.ts +++ b/packages/core/src/sfdxwrappers/CreateDataPackageImpl.ts @@ -43,6 +43,9 @@ export default class CreateDataPackageImpl { ]?.split(","); } + if (MDAPIPackageGenerator.isEmptyFolder(this.projectDirectory,packageDirectory)) { + this.printEmptyArtifactWarning(); + } //Get Artifact Detailes let sourcePackageArtifactDir = SourcePackageGenerator.generateSourcePackageArtifact( diff --git a/packages/core/src/sfdxwrappers/InstallDataPackageImpl.ts b/packages/core/src/sfdxwrappers/InstallDataPackageImpl.ts index 4a593d39d..0f1acd774 100644 --- a/packages/core/src/sfdxwrappers/InstallDataPackageImpl.ts +++ b/packages/core/src/sfdxwrappers/InstallDataPackageImpl.ts @@ -16,25 +16,25 @@ export default class InstallDataPackageImpl { let child = child_process.exec( command, { cwd: path.resolve(this.sourceDirectory), encoding: "utf8" }, - (error, stdout, stderr) => { - if (error) { - throw error; - } - }); + ); child.stdout.on("data", (data) => { console.log(data.toString()); }); + child.stderr.on("data", (data) => { + console.log(data.toString()); + }); + await onExit(child); } catch (err) { + throw err; + } finally { let csvIssuesReportFilepath: string = path.join(this.sourceDirectory, this.packageDirectory, `CSVIssuesReport.csv`) if (fs.existsSync(csvIssuesReportFilepath)) { - console.log(`CSV issues detected:`); + console.log(`\n---------------------WARNING: SFDMU detected CSV issues, verify the following files -------------------------------`); console.log(fs.readFileSync(csvIssuesReportFilepath, 'utf8')); } - - throw err; } } From a1d06ce360116ead5705aca2591112cfcee19356 Mon Sep 17 00:00:00 2001 From: Alan Ly Date: Wed, 14 Oct 2020 21:04:41 +1100 Subject: [PATCH 4/8] Add InstallDataPacakge task in Azp --- lerna.json | 1 + .../PostPackageTaskCheck.ts | 24 + .../CreateDataPackageTask/package.json | 2 +- .../CreateDataPackageTask/task.json | 10 +- .../CreateDataPackageTask/tsconfig.json | 3 +- .../InstallDataPackage.ts | 163 ++++++ .../InstallDataPackageTask/icon.png | Bin 0 -> 2637 bytes .../InstallDataPackageTask/package-lock.json | 515 ++++++++++++++++++ .../InstallDataPackageTask/package.json | 16 + .../InstallDataPackageTask/task.json | 71 +++ .../InstallDataPackageTask/tsconfig.json | 11 + packages/azpipelines/vss-extension.json | 13 + .../src/sfdxwrappers/CreateDataPackageImpl.ts | 8 +- .../sfdxwrappers/InstallDataPackageImpl.ts | 6 +- .../messages/install_data_package.json | 2 - .../sfpowerscripts/CreateDataPackage.ts | 9 +- .../sfpowerscripts/InstallDataPackage.ts | 15 +- 17 files changed, 840 insertions(+), 29 deletions(-) create mode 100644 packages/azpipelines/BuildTasks/CreateDataPackageTask/PostPackageTaskCheck.ts create mode 100644 packages/azpipelines/BuildTasks/InstallDataPackageTask/InstallDataPackage.ts create mode 100644 packages/azpipelines/BuildTasks/InstallDataPackageTask/icon.png create mode 100644 packages/azpipelines/BuildTasks/InstallDataPackageTask/package-lock.json create mode 100644 packages/azpipelines/BuildTasks/InstallDataPackageTask/package.json create mode 100644 packages/azpipelines/BuildTasks/InstallDataPackageTask/task.json create mode 100644 packages/azpipelines/BuildTasks/InstallDataPackageTask/tsconfig.json diff --git a/lerna.json b/lerna.json index b35c1b333..dd620afa6 100644 --- a/lerna.json +++ b/lerna.json @@ -17,6 +17,7 @@ "packages/azpipelines/BuildTasks/IncrementProjectBuildNumberTask", "packages/azpipelines/BuildTasks/InstallPackageDependenciesTask", "packages/azpipelines/BuildTasks/InstallSFDXCLITaskCurrent", + "packages/azpipelines/BuildTasks/InstallDataPackageTask", "packages/azpipelines/BuildTasks/InstallUnlockedPackageTask", "packages/azpipelines/BuildTasks/InstallSourcePackageTask", "packages/azpipelines/BuildTasks/ManageScratchOrgTaskCurrent", diff --git a/packages/azpipelines/BuildTasks/CreateDataPackageTask/PostPackageTaskCheck.ts b/packages/azpipelines/BuildTasks/CreateDataPackageTask/PostPackageTaskCheck.ts new file mode 100644 index 000000000..d43339cc9 --- /dev/null +++ b/packages/azpipelines/BuildTasks/CreateDataPackageTask/PostPackageTaskCheck.ts @@ -0,0 +1,24 @@ +import tl = require("azure-pipelines-task-lib/task"); + +async function run() { + const isGitTag: boolean = tl.getBoolInput("isGitTag", false); + const sfdx_package: string = tl.getInput("package", true); + + if (isGitTag) { + console.log( + `Checking whether Post Package Create Task is added to the pipeline as ${isGitTag} is enabled for ${sfdx_package}` + ); + let isPostPackageTaskExecuted: string = tl.getVariable( + "post_package_task_executed" + ); + + if (isPostPackageTaskExecuted != "true") { + tl.setResult( + tl.TaskResult.SucceededWithIssues, + `Post Package Task not executed/added in the pipeline, Please add it at the end of package creation commands!` + ); + } + } +} + +run(); diff --git a/packages/azpipelines/BuildTasks/CreateDataPackageTask/package.json b/packages/azpipelines/BuildTasks/CreateDataPackageTask/package.json index bb163a216..f978bb021 100644 --- a/packages/azpipelines/BuildTasks/CreateDataPackageTask/package.json +++ b/packages/azpipelines/BuildTasks/CreateDataPackageTask/package.json @@ -10,6 +10,6 @@ "license": "MIT", "dependencies": { "@dxatscale/sfpowerscripts.core": "^2.1.6", - "azure-pipelines-task-lib": "^2.11.3" + "azure-pipelines-task-lib": "^2.8.0" } } diff --git a/packages/azpipelines/BuildTasks/CreateDataPackageTask/task.json b/packages/azpipelines/BuildTasks/CreateDataPackageTask/task.json index 6d6c8d74d..3452fbda5 100644 --- a/packages/azpipelines/BuildTasks/CreateDataPackageTask/task.json +++ b/packages/azpipelines/BuildTasks/CreateDataPackageTask/task.json @@ -1,11 +1,11 @@ { "id": "f33c11ff-5ea2-4502-be51-31d7aa27de6e", "name": "sfpowerscripts-createdatapackage-task", - "friendlyName": "Create a data package", + "friendlyName": "Create a new version of data package", "description": "Creates a versioned artifact from a source directory containing SFDMU-based data (in csv format and export json). The artifact can be consumed by release pipelines, to deploy the data to orgs", "helpMarkDown": "", "category": "Build", - "author": "{{taskauthor}}", + "author": "dxatscale@accenture.com", "version": { "Major": 1, "Minor": 0, @@ -75,5 +75,11 @@ "Node": { "target": "lib/CreateDataPackage.js" } + }, + "postjobexecution": { + "Node": { + "target": "lib/PostPackageTaskCheck.js", + "argumentFormat": "" + } } } diff --git a/packages/azpipelines/BuildTasks/CreateDataPackageTask/tsconfig.json b/packages/azpipelines/BuildTasks/CreateDataPackageTask/tsconfig.json index bb873706c..945adc89a 100644 --- a/packages/azpipelines/BuildTasks/CreateDataPackageTask/tsconfig.json +++ b/packages/azpipelines/BuildTasks/CreateDataPackageTask/tsconfig.json @@ -6,6 +6,7 @@ "composite": false }, "files": [ - "CreateDataPackage.ts" + "CreateDataPackage.ts", + "PostPackageTaskCheck.ts" ] } diff --git a/packages/azpipelines/BuildTasks/InstallDataPackageTask/InstallDataPackage.ts b/packages/azpipelines/BuildTasks/InstallDataPackageTask/InstallDataPackage.ts new file mode 100644 index 000000000..d78ecb8ac --- /dev/null +++ b/packages/azpipelines/BuildTasks/InstallDataPackageTask/InstallDataPackage.ts @@ -0,0 +1,163 @@ +import tl = require("azure-pipelines-task-lib/task"); +import InstallDataPackageImpl from "@dxatscale/sfpowerscripts.core/lib/sfdxwrappers/InstallDataPackageImpl"; +import PackageMetadata from "@dxatscale/sfpowerscripts.core/lib/PackageMetadata"; +import * as ExtensionManagementApi from "azure-devops-node-api/ExtensionManagementApi"; +import { getWebAPIWithoutToken } from "../Common/WebAPIHelper"; +import ArtifactFilePathFetcher from "@dxatscale/sfpowerscripts.core/lib/artifacts/ArtifactFilePathFetcher"; +import ManifestHelpers from "@dxatscale/sfpowerscripts.core/lib/manifest/ManifestHelpers"; +import { + getExtensionName, + fetchPackageArtifactFromStorage, + updatePackageDeploymentDetails, +} from "../Common/PackageExtensionStorageHelper"; +import ArtifactHelper from "../Common/ArtifactHelper"; +const fs = require("fs"); +const path = require("path"); + +async function run() { + try { + console.log("Install Data Package To Org"); + + const target_org: string = tl.getInput("target_org", true); + const sfdx_package: string = tl.getInput("package", true); + const artifactDir = tl.getInput("artifactDir", false); + const skip_on_missing_artifact = tl.getBoolInput( + "skip_on_missing_artifact", + false + ); + const subdirectory: string = tl.getInput("subdirectory", false); + const skip_if_package_installed: boolean = tl.getBoolInput( + "skip_if_package_installed", + false + ); + + //WebAPI Initialization + const webApi = await getWebAPIWithoutToken(); + const extensionManagementApi: ExtensionManagementApi.IExtensionManagementApi = await webApi.getExtensionManagementApi(); + let extensionName = await getExtensionName(extensionManagementApi); + + //Fetch Artifact + let artifacts_filepaths = ArtifactFilePathFetcher.fetchArtifactFilePaths( + ArtifactHelper.getArtifactDirectory(artifactDir), + sfdx_package + ); + console.log( + "##[debug]Artifacts Paths", + JSON.stringify(artifacts_filepaths) + ); + + ArtifactHelper.skipTaskWhenArtifactIsMissing( + ArtifactFilePathFetcher.missingArtifactDecider( + artifacts_filepaths, + skip_on_missing_artifact + ) + ); + + let packageMetadataFromArtifact: PackageMetadata = JSON.parse( + fs.readFileSync(artifacts_filepaths[0].packageMetadataFilePath, "utf8") + ); + + let packageMetadataFromStorage: PackageMetadata = await fetchPackageArtifactFromStorage( + packageMetadataFromArtifact, + extensionManagementApi, + extensionName + ); + + console.log( + "##[command]Package Metadata:" + + JSON.stringify(packageMetadataFromArtifact) + ); + + if ( + skip_if_package_installed && + checkPackageIsInstalled( + packageMetadataFromStorage, + target_org, + subdirectory + ) + ) { + tl.setResult( + tl.TaskResult.Skipped, + "Skipping Package Installation as already installed" + ); + return; + } + + let sourceDirectory; + // Get package source directory from sfdx-project.json in sourceDirectoryPath + sourceDirectory = ManifestHelpers.getSFDXPackageDescriptor( + artifacts_filepaths[0].sourceDirectoryPath, + sfdx_package + )["path"]; + + console.log("Path for the project", sourceDirectory); + if (subdirectory != null) { + sourceDirectory = path.join(sourceDirectory, subdirectory); + + // Check whether the absolute source directory path exists + let absSourceDirectory = path.join( + artifacts_filepaths[0].sourceDirectoryPath, + sourceDirectory + ); + if (!fs.existsSync(absSourceDirectory)) { + throw new Error(`Source directory ${absSourceDirectory} does not exist`); + } + } + + let installDataPackageImpl: InstallDataPackageImpl = new InstallDataPackageImpl( + target_org, + artifacts_filepaths[0].sourceDirectoryPath, + sourceDirectory + ) + + await installDataPackageImpl.exec(); + + + //No environment info available, create and push + if (packageMetadataFromStorage.deployments == null) { + packageMetadataFromStorage.deployments = new Array(); + packageMetadataFromStorage.deployments.push({ + target_org: target_org, + sub_directory: subdirectory, + }); + } else { + //Update existing environment map + packageMetadataFromStorage.deployments.push({ + target_org: target_org, + sub_directory: subdirectory, + }); + } + + await updatePackageDeploymentDetails( + packageMetadataFromStorage, + extensionManagementApi, + extensionName + ); + + tl.setResult(tl.TaskResult.Succeeded, "Package installed successfully"); + + } catch (err) { + tl.setResult(tl.TaskResult.Failed, err.message); + } +} + + +function checkPackageIsInstalled( + packageMetadata: PackageMetadata, + target_org: string, + subdirectory: string +) { + if (packageMetadata.deployments != null) { + for (const deployment of packageMetadata.deployments) { + if ( + target_org == deployment.target_org && + subdirectory == deployment.sub_directory + ) { + return true; + } + } + } + return false; +} + +run(); diff --git a/packages/azpipelines/BuildTasks/InstallDataPackageTask/icon.png b/packages/azpipelines/BuildTasks/InstallDataPackageTask/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..36b0bcad4f52d1b018ed0d3cdaee1be70addd1fb GIT binary patch literal 2637 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 literal 0 HcmV?d00001 diff --git a/packages/azpipelines/BuildTasks/InstallDataPackageTask/package-lock.json b/packages/azpipelines/BuildTasks/InstallDataPackageTask/package-lock.json new file mode 100644 index 000000000..ea4606ac4 --- /dev/null +++ b/packages/azpipelines/BuildTasks/InstallDataPackageTask/package-lock.json @@ -0,0 +1,515 @@ +{ + "name": "sfpowerscripts-installdatapackage-task", + "version": "1.0.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "@dxatscale/sfpowerscripts.core": { + "version": "2.1.6", + "resolved": "https://registry.npmjs.org/@dxatscale/sfpowerscripts.core/-/sfpowerscripts.core-2.1.6.tgz", + "integrity": "sha512-o2q+nRmk2ON1k8VCk85/UTosOPpz8kOUyQmRp2mHeGAfG/P9FHGl+McbrUcioHxseCquP0snE/ud2q7xd5weIw==", + "requires": { + "antlr4ts": "^0.5.0-alpha.3", + "apex-parser": "^2.5.0", + "async-retry": "^1.3.1", + "cli-table": "^0.3.1", + "fs-extra": "^8.1.0", + "glob": "^7.1.6", + "ignore": "^5.1.6", + "rimraf": "^3.0.2", + "shelljs": "^0.8.4", + "simple-git": "2.0.0", + "unzip-stream": "0.3.0", + "xml2js": "^0.4.23" + }, + "dependencies": { + "shelljs": { + "version": "0.8.4", + "resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.8.4.tgz", + "integrity": "sha512-7gk3UZ9kOfPLIAbslLzyWeGiEqx9e3rxwZM0KE6EL8GlGwjym9Mrlx5/p33bWTu9YG6vcS4MBxYZDHYr5lr8BQ==", + "requires": { + "glob": "^7.0.0", + "interpret": "^1.0.0", + "rechoir": "^0.6.2" + } + } + } + }, + "@kwsites/exec-p": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/@kwsites/exec-p/-/exec-p-0.4.0.tgz", + "integrity": "sha512-44DWNv5gDR9EwrCTVQ4ZC99yPqVS0VCWrYIBl45qNR8XQy+4lbl0IQG8kBDf6NHwj4Ib4c2z1Fq1IUJOCbkZcw==" + }, + "antlr4ts": { + "version": "0.5.0-alpha.3", + "resolved": "https://registry.npmjs.org/antlr4ts/-/antlr4ts-0.5.0-alpha.3.tgz", + "integrity": "sha512-La89tKkGcHFIVuruv4Bm1esc3zLmES2NOTEwwNS1pudz+zx/0FNqQeUu9p48i9/QHKPVqjN87LB+q3buTg7oDQ==" + }, + "apex-parser": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/apex-parser/-/apex-parser-2.5.0.tgz", + "integrity": "sha512-rXZyVgbUSmotjnPTVlJSP8fhIiRwFT6373X6rEwedSC9QorZSV+SqHKy+lhzJCVHUpLIzGXjGRCdtYZLlwkf4Q==", + "requires": { + "antlr4ts": "^0.5.0-alpha.3" + } + }, + "asap": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz", + "integrity": "sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY=" + }, + "async-retry": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/async-retry/-/async-retry-1.3.1.tgz", + "integrity": "sha512-aiieFW/7h3hY0Bq5d+ktDBejxuwR78vRu9hDUdR8rNhSaQ29VzPL4AoIRG7D/c7tdenwOcKvgPM6tIxB3cB6HA==", + "requires": { + "retry": "0.12.0" + } + }, + "azure-devops-node-api": { + "version": "10.1.1", + "resolved": "https://registry.npmjs.org/azure-devops-node-api/-/azure-devops-node-api-10.1.1.tgz", + "integrity": "sha512-P4Hyrh/+Nzc2KXQk73z72/GsenSWIH5o8uiyELqykJYs9TWTVCxVwghoR7lPeiY6QVoXkq2S2KtvAgi5fyjl9w==", + "requires": { + "tunnel": "0.0.6", + "typed-rest-client": "^1.7.3", + "underscore": "1.8.3" + } + }, + "azure-pipelines-task-lib": { + "version": "2.11.3", + "resolved": "https://registry.npmjs.org/azure-pipelines-task-lib/-/azure-pipelines-task-lib-2.11.3.tgz", + "integrity": "sha512-gXops6Npkloh7AKPIvptx0KY1kdf1yd+BFdp/ksnbyW7CS3uXzBQXU1Dermr7A895TrOd02PI6hmsL8cBlePNA==", + "requires": { + "minimatch": "3.0.4", + "mockery": "^1.7.0", + "q": "^1.1.2", + "semver": "^5.1.0", + "shelljs": "^0.3.0", + "sync-request": "3.0.1", + "uuid": "^3.0.1" + } + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" + }, + "binary": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/binary/-/binary-0.3.0.tgz", + "integrity": "sha1-n2BVO8XOjDOG87VTz/R0Yq3sqnk=", + "requires": { + "buffers": "~0.1.1", + "chainsaw": "~0.1.0" + } + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "buffer-from": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", + "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==" + }, + "buffers": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/buffers/-/buffers-0.1.1.tgz", + "integrity": "sha1-skV5w77U1tOWru5tmorn9Ugqt7s=" + }, + "caseless": { + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.11.0.tgz", + "integrity": "sha1-cVuW6phBWTzDMGeSP17GDr2k99c=" + }, + "chainsaw": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/chainsaw/-/chainsaw-0.1.0.tgz", + "integrity": "sha1-XqtQsor+WAdNDVgpE4iCi15fvJg=", + "requires": { + "traverse": ">=0.3.0 <0.4" + } + }, + "cli-table": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/cli-table/-/cli-table-0.3.1.tgz", + "integrity": "sha1-9TsFJmqLGguTSz0IIebi3FkUriM=", + "requires": { + "colors": "1.0.3" + } + }, + "colors": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/colors/-/colors-1.0.3.tgz", + "integrity": "sha1-BDP0TYCWgP3rYO0mDxsMJi6CpAs=" + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" + }, + "concat-stream": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", + "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", + "requires": { + "buffer-from": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^2.2.2", + "typedarray": "^0.0.6" + } + }, + "core-util-is": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" + }, + "debug": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.2.0.tgz", + "integrity": "sha512-IX2ncY78vDTjZMFUdmsvIRFY2Cf4FnD0wRs+nQwJU8Lu99/tPFdb0VybiiMTPe3I6rQmwsqQqRBvxU+bZ/I8sg==", + "requires": { + "ms": "2.1.2" + } + }, + "fs-extra": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz", + "integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==", + "requires": { + "graceful-fs": "^4.2.0", + "jsonfile": "^4.0.0", + "universalify": "^0.1.0" + } + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" + }, + "glob": { + "version": "7.1.6", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", + "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "graceful-fs": { + "version": "4.2.4", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.4.tgz", + "integrity": "sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw==" + }, + "http-basic": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/http-basic/-/http-basic-2.5.1.tgz", + "integrity": "sha1-jORHvbW2xXf4pj4/p4BW7Eu02/s=", + "requires": { + "caseless": "~0.11.0", + "concat-stream": "^1.4.6", + "http-response-object": "^1.0.0" + } + }, + "http-response-object": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/http-response-object/-/http-response-object-1.1.0.tgz", + "integrity": "sha1-p8TnWq6C87tJBOT0P2FWc7TVGMM=" + }, + "ignore": { + "version": "5.1.8", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.1.8.tgz", + "integrity": "sha512-BMpfD7PpiETpBl/A6S498BaIJ6Y/ABT93ETbby2fP00v4EbvPBXWEoaR1UBPKs3iR53pJY7EtZk5KACI57i1Uw==" + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + }, + "interpret": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/interpret/-/interpret-1.4.0.tgz", + "integrity": "sha512-agE4QfB2Lkp9uICn7BAqoscw4SZP9kTE2hxiFI3jBPmXJfdqiahTbUuKGsMoN2GtqL9AxhYioAcVvgsb1HvRbA==" + }, + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" + }, + "jsonfile": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", + "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", + "requires": { + "graceful-fs": "^4.1.6" + } + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "minimist": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", + "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==" + }, + "mkdirp": { + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", + "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", + "requires": { + "minimist": "^1.2.5" + } + }, + "mockery": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/mockery/-/mockery-1.7.0.tgz", + "integrity": "sha1-9O3g2HUMHJcnwnLqLGBiniyaHE8=" + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "requires": { + "wrappy": "1" + } + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" + }, + "path-parse": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", + "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==" + }, + "process-nextick-args": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", + "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==" + }, + "promise": { + "version": "7.3.1", + "resolved": "https://registry.npmjs.org/promise/-/promise-7.3.1.tgz", + "integrity": "sha512-nolQXZ/4L+bP/UGlkfaIujX9BKxGwmQ9OT4mOt5yvy8iK1h3wqTEJCijzGANTCCl9nWjY41juyAn2K3Q1hLLTg==", + "requires": { + "asap": "~2.0.3" + } + }, + "q": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/q/-/q-1.5.1.tgz", + "integrity": "sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc=" + }, + "qs": { + "version": "6.9.4", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.9.4.tgz", + "integrity": "sha512-A1kFqHekCTM7cz0udomYUoYNWjBebHm/5wzU/XqrBRBNWectVH0QIiN+NEcZ0Dte5hvzHwbr8+XQmguPhJ6WdQ==" + }, + "readable-stream": { + "version": "2.3.7", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", + "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "rechoir": { + "version": "0.6.2", + "resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.6.2.tgz", + "integrity": "sha1-hSBLVNuoLVdC4oyWdW70OvUOM4Q=", + "requires": { + "resolve": "^1.1.6" + } + }, + "resolve": { + "version": "1.17.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.17.0.tgz", + "integrity": "sha512-ic+7JYiV8Vi2yzQGFWOkiZD5Z9z7O2Zhm9XMaTxdJExKasieFCr+yXZ/WmXsckHiKl12ar0y6XiXDx3m4RHn1w==", + "requires": { + "path-parse": "^1.0.6" + } + }, + "retry": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/retry/-/retry-0.12.0.tgz", + "integrity": "sha1-G0KmJmoh8HQh0bC1S33BZ7AcATs=" + }, + "rimraf": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", + "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", + "requires": { + "glob": "^7.1.3" + } + }, + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + }, + "sax": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz", + "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==" + }, + "semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==" + }, + "shelljs": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.3.0.tgz", + "integrity": "sha1-NZbmMHp4FUT1kfN9phg2DzHbV7E=" + }, + "simple-git": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/simple-git/-/simple-git-2.0.0.tgz", + "integrity": "sha512-R7P9WfnHmwnUlRowXGT93FOhhGvRQWWGhgH6Nf3lCXOv4SjtAuK25Tfhf4VFYueQ11r4WDMUVLXtKFGWPwLehg==", + "requires": { + "@kwsites/exec-p": "^0.4.0", + "debug": "^4.0.1" + } + }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "requires": { + "safe-buffer": "~5.1.0" + } + }, + "sync-request": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/sync-request/-/sync-request-3.0.1.tgz", + "integrity": "sha1-yqEjWq+Im6UBB2oYNMQ2gwqC+3M=", + "requires": { + "concat-stream": "^1.4.7", + "http-response-object": "^1.0.1", + "then-request": "^2.0.1" + } + }, + "then-request": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/then-request/-/then-request-2.2.0.tgz", + "integrity": "sha1-ZnizL6DKIY/laZgbvYhxtZQGDYE=", + "requires": { + "caseless": "~0.11.0", + "concat-stream": "^1.4.7", + "http-basic": "^2.5.1", + "http-response-object": "^1.1.0", + "promise": "^7.1.1", + "qs": "^6.1.0" + } + }, + "traverse": { + "version": "0.3.9", + "resolved": "https://registry.npmjs.org/traverse/-/traverse-0.3.9.tgz", + "integrity": "sha1-cXuPIgzAu3tE5AUUwisui7xw2Lk=" + }, + "tunnel": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.6.tgz", + "integrity": "sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==" + }, + "typed-rest-client": { + "version": "1.7.3", + "resolved": "https://registry.npmjs.org/typed-rest-client/-/typed-rest-client-1.7.3.tgz", + "integrity": "sha512-CwTpx/TkRHGZoHkJhBcp4X8K3/WtlzSHVQR0OIFnt10j4tgy4ypgq/SrrgVpA1s6tAL49Q6J3R5C0Cgfh2ddqA==", + "requires": { + "qs": "^6.9.1", + "tunnel": "0.0.6", + "underscore": "1.8.3" + } + }, + "typedarray": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", + "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=" + }, + "underscore": { + "version": "1.8.3", + "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.8.3.tgz", + "integrity": "sha1-Tz+1OxBuYJf8+ctBCfKl6b36UCI=" + }, + "universalify": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", + "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==" + }, + "unzip-stream": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/unzip-stream/-/unzip-stream-0.3.0.tgz", + "integrity": "sha512-NG1h/MdGIX3HzyqMjyj1laBCmlPYhcO4xEy7gEqqzGiSLw7XqDQCnY4nYSn5XSaH8mQ6TFkaujrO8d/PIZN85A==", + "requires": { + "binary": "^0.3.0", + "mkdirp": "^0.5.1" + } + }, + "util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" + }, + "uuid": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", + "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==" + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" + }, + "xml2js": { + "version": "0.4.23", + "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.23.tgz", + "integrity": "sha512-ySPiMjM0+pLDftHgXY4By0uswI3SPKLDw/i3UXbnO8M/p28zqexCUoPmQFrYD+/1BzhGJSs2i1ERWKJAtiLrug==", + "requires": { + "sax": ">=0.6.0", + "xmlbuilder": "~11.0.0" + } + }, + "xmlbuilder": { + "version": "11.0.1", + "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-11.0.1.tgz", + "integrity": "sha512-fDlsI/kFEx7gLvbecc0/ohLG50fugQp8ryHzMTuW9vSa1GJ0XYWKnhsUx7oie3G98+r56aTQIUB4kht42R3JvA==" + } + } +} diff --git a/packages/azpipelines/BuildTasks/InstallDataPackageTask/package.json b/packages/azpipelines/BuildTasks/InstallDataPackageTask/package.json new file mode 100644 index 000000000..e34021167 --- /dev/null +++ b/packages/azpipelines/BuildTasks/InstallDataPackageTask/package.json @@ -0,0 +1,16 @@ +{ + "name": "sfpowerscripts-installdatapackage-task", + "description": "sfpowerscripts-installdatapackage-task", + "version": "1.0.0", + "private": true, + "scripts": { + "version": "node ../../versionupdate.js && git add task.json", + "build": "rimraf lib && tsc -b" + }, + "license": "MIT", + "dependencies": { + "@dxatscale/sfpowerscripts.core": "^2.1.6", + "azure-devops-node-api": "^10.1.1", + "azure-pipelines-task-lib": "^2.8.0" + } +} diff --git a/packages/azpipelines/BuildTasks/InstallDataPackageTask/task.json b/packages/azpipelines/BuildTasks/InstallDataPackageTask/task.json new file mode 100644 index 000000000..f11efe746 --- /dev/null +++ b/packages/azpipelines/BuildTasks/InstallDataPackageTask/task.json @@ -0,0 +1,71 @@ +{ + "id": "255e630b-61e3-4bcc-a22d-5adab8693111", + "name": "sfpowerscripts-installdatapackage-task", + "friendlyName": "Install a data package to an org", + "description": "Installs a SFDMU-based data package consisting of csvfiles and export.json to a target org", + "helpMarkDown": "", + "category": "Deploy", + "author": "dxatscale@accenture.com", + "version": { + "Major": 1, + "Minor": 0, + "Patch": 0 + }, + "runsOn": [ + "Agent" + ], + "instanceNameFormat": "Install a $(package) data package to $(target_org)", + "inputs": [ + { + "name": "target_org", + "type": "string", + "label": "Alias or username of the target org", + "defaultValue": "scratchorg", + "required": true, + "helpMarkDown": "Alias or username of the target org where the code should be deployed" + }, + { + "name": "package", + "type": "string", + "label": "Name of the package to be installed", + "required": true, + "helpMarkDown": "Name of the package to be installed" + }, + { + "name": "aritfactDir", + "type": "string", + "label": "Path to the directory where artifacts are downloaded", + "defaultValue": "", + "required": false, + "helpMarkDown": "Path to the artifact directory where the artifacts are downloaded, If not provided, the default values will be automatically used" + }, + { + "name": "subdirectory", + "type": "string", + "label": "Install only a specific folder in the package", + "required": false, + "helpMarkDown": "Install only a specific folder in the package" + }, + { + "name": "skip_if_package_installed", + "type": "boolean", + "label": "Skip If the package is already installed in the org", + "defaultValue": false, + "required": false, + "helpMarkDown": "Skip installation of package, if its already installed in the org" + }, + { + "name": "skip_on_missing_artifact", + "type": "boolean", + "label": "Skip If no artifact is found", + "defaultValue": false, + "required": false, + "helpMarkDown": "Do not fail the task if attached artifact is missing,Use it to skip artifact installation by removing attached artifacts" + } + ], + "execution": { + "Node": { + "target": "lib/InstallDataPackageTask/InstallDataPackage.js" + } + } +} diff --git a/packages/azpipelines/BuildTasks/InstallDataPackageTask/tsconfig.json b/packages/azpipelines/BuildTasks/InstallDataPackageTask/tsconfig.json new file mode 100644 index 000000000..6064ca213 --- /dev/null +++ b/packages/azpipelines/BuildTasks/InstallDataPackageTask/tsconfig.json @@ -0,0 +1,11 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "outDir": "./lib", + "sourceRoot": "./", + "composite": false + }, + "files": [ + "InstallDataPackage.ts" + ] +} diff --git a/packages/azpipelines/vss-extension.json b/packages/azpipelines/vss-extension.json index d6963623f..3d303c715 100644 --- a/packages/azpipelines/vss-extension.json +++ b/packages/azpipelines/vss-extension.json @@ -119,6 +119,9 @@ { "path": "BuildTasks/IncrementProjectBuildNumberTask" }, + { + "path": "BuildTasks/InstallDataPackageTask" + }, { "path": "BuildTasks/InstallUnlockedPackageTask" }, @@ -387,6 +390,16 @@ "name": "BuildTasks/IncrementProjectBuildNumberTask" } }, + { + "id": "sfpowerscripts-installdatapackage-task", + "type": "ms.vss-distributed-task.task", + "targets": [ + "ms.vss-distributed-task.tasks" + ], + "properties": { + "name": "BuildTasks/InstallDataPackageTask" + } + }, { "id": "sfpwowerscript-installunlockedpackage-task", "type": "ms.vss-distributed-task.task", diff --git a/packages/core/src/sfdxwrappers/CreateDataPackageImpl.ts b/packages/core/src/sfdxwrappers/CreateDataPackageImpl.ts index decdf58e3..3282f253b 100644 --- a/packages/core/src/sfdxwrappers/CreateDataPackageImpl.ts +++ b/packages/core/src/sfdxwrappers/CreateDataPackageImpl.ts @@ -2,13 +2,7 @@ import PackageMetadata from "../PackageMetadata"; import SourcePackageGenerator from "../generators/SourcePackageGenerator"; import ManifestHelpers from "../manifest/ManifestHelpers"; import MDAPIPackageGenerator from "../generators/MDAPIPackageGenerator"; -import { isNullOrUndefined } from "util"; -import { EOL } from "os"; -const fs = require("fs-extra"); -import path = require("path"); -import ApexTypeFetcher, { FileDescriptor } from "../parser/ApexTypeFetcher"; -const Table = require("cli-table"); export default class CreateDataPackageImpl { public constructor( @@ -18,6 +12,8 @@ export default class CreateDataPackageImpl { ) {} public async exec(): Promise { + this.packageArtifactMetadata.package_type = "data"; + console.log( "--------------Create Data Package---------------------------" ); diff --git a/packages/core/src/sfdxwrappers/InstallDataPackageImpl.ts b/packages/core/src/sfdxwrappers/InstallDataPackageImpl.ts index 0f1acd774..ec6895362 100644 --- a/packages/core/src/sfdxwrappers/InstallDataPackageImpl.ts +++ b/packages/core/src/sfdxwrappers/InstallDataPackageImpl.ts @@ -6,7 +6,7 @@ const path = require("path"); export default class InstallDataPackageImpl { public constructor( private targetusername: string, - private sourceDirectory: string, + private projectDirectory: string, private packageDirectory: string ) {} @@ -15,7 +15,7 @@ export default class InstallDataPackageImpl { let command = this.buildExecCommand(); let child = child_process.exec( command, - { cwd: path.resolve(this.sourceDirectory), encoding: "utf8" }, + { cwd: path.resolve(this.projectDirectory), encoding: "utf8" }, ); child.stdout.on("data", (data) => { @@ -30,7 +30,7 @@ export default class InstallDataPackageImpl { } catch (err) { throw err; } finally { - let csvIssuesReportFilepath: string = path.join(this.sourceDirectory, this.packageDirectory, `CSVIssuesReport.csv`) + let csvIssuesReportFilepath: string = path.join(this.projectDirectory, this.packageDirectory, `CSVIssuesReport.csv`) if (fs.existsSync(csvIssuesReportFilepath)) { console.log(`\n---------------------WARNING: SFDMU detected CSV issues, verify the following files -------------------------------`); console.log(fs.readFileSync(csvIssuesReportFilepath, 'utf8')); diff --git a/packages/sfpowerscripts-cli/messages/install_data_package.json b/packages/sfpowerscripts-cli/messages/install_data_package.json index e1349d785..b128041e6 100644 --- a/packages/sfpowerscripts-cli/messages/install_data_package.json +++ b/packages/sfpowerscripts-cli/messages/install_data_package.json @@ -4,7 +4,5 @@ "targetOrgFlagDescription": "Alias/User Name of the target environment", "artifactDirectoryFlagDescription": "The directory where the artifact is located", "skipOnMissingArtifactFlagDescription": "Skip package installation if the build artifact is missing. Enable this if artifacts are only being created for modified packages", - "skipIfAlreadyInstalled":"Skip the package installation if the package is already installed in the org", - "noPromptFlagDescription": "Skip prompt inputs or confirmation", "subdirectoryFlagDescription": "Install specific subdirectory in the package. Useful when package consists of multiple discrete sub-packages" } diff --git a/packages/sfpowerscripts-cli/src/commands/sfpowerscripts/CreateDataPackage.ts b/packages/sfpowerscripts-cli/src/commands/sfpowerscripts/CreateDataPackage.ts index ed0f30cfb..ba25a9e6f 100644 --- a/packages/sfpowerscripts-cli/src/commands/sfpowerscripts/CreateDataPackage.ts +++ b/packages/sfpowerscripts-cli/src/commands/sfpowerscripts/CreateDataPackage.ts @@ -63,14 +63,13 @@ export default class CreateDataPackage extends SfpowerscriptsCommand { if (runBuild) { let commit_id = exec('git log --pretty=format:%H -n 1', {silent:true}).stdout; - console.log(commit_id); + let repository_url: string; if (this.flags.repourl == null) { repository_url = exec('git config --get remote.origin.url', {silent:true}); // Remove new line '\n' from end of url repository_url = repository_url.slice(0,repository_url.length - 1); } else repository_url = this.flags.repourl; - console.log(repository_url); let packageMetadata:PackageMetadata = { @@ -78,7 +77,6 @@ export default class CreateDataPackage extends SfpowerscriptsCommand { package_version_number: version_number, sourceVersion: commit_id, repository_url:repository_url, - package_type:"data", apextestsuite: null }; fs.writeFileSync(`test.json`, JSON.stringify(packageMetadata, null, 4)); @@ -90,10 +88,7 @@ export default class CreateDataPackage extends SfpowerscriptsCommand { ); packageMetadata = await createDataPackageImpl.exec(); - console.log(JSON.stringify(packageMetadata, function(key, val) { - if (key !== "payload") - return val; - })); + console.log(JSON.stringify(packageMetadata)); //Generate Artifact diff --git a/packages/sfpowerscripts-cli/src/commands/sfpowerscripts/InstallDataPackage.ts b/packages/sfpowerscripts-cli/src/commands/sfpowerscripts/InstallDataPackage.ts index cc49c50a0..85a443d75 100644 --- a/packages/sfpowerscripts-cli/src/commands/sfpowerscripts/InstallDataPackage.ts +++ b/packages/sfpowerscripts-cli/src/commands/sfpowerscripts/InstallDataPackage.ts @@ -18,18 +18,16 @@ export default class InstallDataPackage extends SfpowerscriptsCommand { public static description = messages.getMessage('commandDescription'); public static examples = [ - `$ sfdx sfpowerscripts:InstallDataPackage ` + `$ sfdx sfpowerscripts:InstallDataPackage -n mypackage -u ` ]; protected static flagsConfig = { - package: flags.string({char: 'n', description: messages.getMessage('packageFlagDescription')}), - targetorg: flags.string({char: 'u', description: messages.getMessage('targetOrgFlagDescription')}), + package: flags.string({char: 'n', description: messages.getMessage('packageFlagDescription'), required: true}), + targetorg: flags.string({char: 'u', description: messages.getMessage('targetOrgFlagDescription'), required: true}), artifactdir: flags.directory({description: messages.getMessage('artifactDirectoryFlagDescription'), default: 'artifacts'}), - skipifalreadyinstalled: flags.boolean({char: "f",description: messages.getMessage("skipIfAlreadyInstalled")}), skiponmissingartifact: flags.boolean({description: messages.getMessage('skipOnMissingArtifactFlagDescription'), dependsOn: ['packageinstalledfrom']}), - noprompt: flags.boolean({description: messages.getMessage('noPromptFlagDescription')}), - subdirectory: flags.directory({description: messages.getMessage('subdirectoryFlagDescription')}), + subdirectory: flags.directory({description: messages.getMessage('subdirectoryFlagDescription')}) }; protected static requiresUsername = false; @@ -43,7 +41,6 @@ export default class InstallDataPackage extends SfpowerscriptsCommand { let skip_on_missing_artifact: boolean = this.flags.skiponmissingartifact; const artifact_directory: string = this.flags.artifactdir; - const skipIfAlreadyInstalled = this.flags.skipifalreadyinstalled; const subdirectory: string = this.flags.subdirectory; @@ -91,6 +88,10 @@ export default class InstallDataPackage extends SfpowerscriptsCommand { ) } + let absPackageDirectory: string = path.join(sourceDirectory, packageDirectory); + if (!fs.existsSync(absPackageDirectory)) { + throw new Error(`Source directory ${absPackageDirectory} does not exist`) + } let installDataPackageImpl: InstallDataPackageImpl = new InstallDataPackageImpl( targetOrg, From f6c9787ebf6e8a284da05e6f3bbba296939c79bc Mon Sep 17 00:00:00 2001 From: Alan Ly Date: Thu, 15 Oct 2020 10:56:36 +1100 Subject: [PATCH 5/8] Add create data package to build impl --- .vscode/settings.json | 5 +- .../CreateDataPackage.ts | 7 +- .../CreateDataPackageTask/task.json | 10 +-- .../CreateSourcePackage.ts | 3 +- .../InstallDataPackageTask/task.json | 2 +- .../PostPackageCreate.ts | 2 +- packages/core/src/manifest/ManifestHelpers.ts | 5 +- packages/core/src/sfdxwrappers/BuildImpl.ts | 64 ++++++++++++++++--- .../src/sfdxwrappers/CreateDataPackageImpl.ts | 56 ++++++++++++---- .../sfpowerscripts/CreateDataPackage.ts | 11 ++-- .../sfpowerscripts/CreateSourcePackage.ts | 3 +- 11 files changed, 123 insertions(+), 45 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 69b7abab0..349eac37a 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -8,5 +8,6 @@ "**/node_modules":true, "packages/azpipelines/build":true, "**/lib":true - } -} \ No newline at end of file + }, + "editor.tabSize": 2 +} diff --git a/packages/azpipelines/BuildTasks/CreateDataPackageTask/CreateDataPackage.ts b/packages/azpipelines/BuildTasks/CreateDataPackageTask/CreateDataPackage.ts index e7f865e68..60ef2dd14 100644 --- a/packages/azpipelines/BuildTasks/CreateDataPackageTask/CreateDataPackage.ts +++ b/packages/azpipelines/BuildTasks/CreateDataPackageTask/CreateDataPackage.ts @@ -41,8 +41,7 @@ async function run() { package_name: sfdx_package, package_version_number: version_number, sourceVersion: commitId, - repository_url: repositoryUrl, - apextestsuite:null + repository_url: repositoryUrl }; @@ -66,11 +65,11 @@ async function run() { tl.setVariable("sfpowerscripts_package_version_number", version_number); tl.setVariable( - "sfpowerscripts_source_package_metadata_path", + "sfpowerscripts_data_package_metadata_path", artifact.artifactMetadataFilePath ); tl.setVariable( - "sfpowerscripts_source_package_path", + "sfpowerscripts_data_package_path", artifact.artifactSourceDirectory ); diff --git a/packages/azpipelines/BuildTasks/CreateDataPackageTask/task.json b/packages/azpipelines/BuildTasks/CreateDataPackageTask/task.json index 3452fbda5..1b780c20e 100644 --- a/packages/azpipelines/BuildTasks/CreateDataPackageTask/task.json +++ b/packages/azpipelines/BuildTasks/CreateDataPackageTask/task.json @@ -63,21 +63,21 @@ "description": "The version number of the package that was created" }, { - "name": "sfpowerscripts_source_package_metadata_path", + "name": "sfpowerscripts_data_package_metadata_path", "description": "The path to the metadata artifact created by this task" }, { - "name": "sfpowerscripts_source_package_path", - "description": "The path to source artifact built by this task" + "name": "sfpowerscripts_data_package_path", + "description": "The path to data pacakge artifact built by this task" } ], "execution": { - "Node": { + "Node10": { "target": "lib/CreateDataPackage.js" } }, "postjobexecution": { - "Node": { + "Node10": { "target": "lib/PostPackageTaskCheck.js", "argumentFormat": "" } diff --git a/packages/azpipelines/BuildTasks/CreateSourcePackageTask/CreateSourcePackage.ts b/packages/azpipelines/BuildTasks/CreateSourcePackageTask/CreateSourcePackage.ts index 1232bbadf..75d68cd06 100644 --- a/packages/azpipelines/BuildTasks/CreateSourcePackageTask/CreateSourcePackage.ts +++ b/packages/azpipelines/BuildTasks/CreateSourcePackageTask/CreateSourcePackage.ts @@ -46,8 +46,7 @@ async function run() { package_name: sfdx_package, package_version_number: version_number, sourceVersion: commitId, - repository_url: repositoryUrl, - apextestsuite:null + repository_url: repositoryUrl }; //Convert to MDAPI diff --git a/packages/azpipelines/BuildTasks/InstallDataPackageTask/task.json b/packages/azpipelines/BuildTasks/InstallDataPackageTask/task.json index f11efe746..df13ccf9d 100644 --- a/packages/azpipelines/BuildTasks/InstallDataPackageTask/task.json +++ b/packages/azpipelines/BuildTasks/InstallDataPackageTask/task.json @@ -64,7 +64,7 @@ } ], "execution": { - "Node": { + "Node10": { "target": "lib/InstallDataPackageTask/InstallDataPackage.js" } } diff --git a/packages/azpipelines/BuildTasks/PostPackageCreateTask/PostPackageCreate.ts b/packages/azpipelines/BuildTasks/PostPackageCreateTask/PostPackageCreate.ts index eafdf903b..5c8ba2426 100644 --- a/packages/azpipelines/BuildTasks/PostPackageCreateTask/PostPackageCreate.ts +++ b/packages/azpipelines/BuildTasks/PostPackageCreateTask/PostPackageCreate.ts @@ -46,7 +46,7 @@ async function createandPushGitTag( await git.addConfig("user.email", "sfpowerscripts@dxscale"); - await git.silent(false).addAnnotatedTag(tagname, "Unlocked Package"); + await git.silent(false).addAnnotatedTag(tagname, "sfpowerscripts Package"); console.log(`Created tag ${tagname}`); diff --git a/packages/core/src/manifest/ManifestHelpers.ts b/packages/core/src/manifest/ManifestHelpers.ts index 20e22f2f1..29795c8d7 100644 --- a/packages/core/src/manifest/ManifestHelpers.ts +++ b/packages/core/src/manifest/ManifestHelpers.ts @@ -50,7 +50,10 @@ export default class ManifestHelpers { if (projectConfig["packageAliases"][sfdxPackage]) { return "Unlocked"; } else { - return "Source"; + if (projectConfig["packageDirectories"][sfdxPackage].type.toLowerCase() === "data") + return "Data"; + else + return "Source"; } } } diff --git a/packages/core/src/sfdxwrappers/BuildImpl.ts b/packages/core/src/sfdxwrappers/BuildImpl.ts index e3ed3a783..0f7d74ff0 100644 --- a/packages/core/src/sfdxwrappers/BuildImpl.ts +++ b/packages/core/src/sfdxwrappers/BuildImpl.ts @@ -7,6 +7,7 @@ import { exec } from "shelljs"; import CreateUnlockedPackageImpl from "./CreateUnlockedPackageImpl"; import ManifestHelpers from "../manifest/ManifestHelpers"; import CreateSourcePackageImpl from "./CreateSourcePackageImpl"; +import CreateDataPackageImpl from "./CreateDataPackageImpl"; import IncrementProjectBuildNumberImpl from "./IncrementProjectBuildNumberImpl"; import SFPLogger from "../utils/SFPLogger"; import { EOL } from "os"; @@ -16,6 +17,7 @@ const fs = require("fs-extra"); const PRIORITY_UNLOCKED_PKG_WITH_DEPENDENCY = 1; const PRIORITY_UNLOCKED_PKG_WITHOUT_DEPENDENCY = 3; const PRIORITY_SOURCE_PKG = 5; +const PRIORITY_DATA_PKG = 5; export default class BuildImpl { private limiter: Bottleneck; private parentsToBeFulfilled; @@ -62,7 +64,7 @@ export default class BuildImpl { this.project_directory ); - + rimraf.sync(".sfpowerscripts"); @@ -86,7 +88,7 @@ export default class BuildImpl { SFPLogger.isSupressLogs = true; //List all package that will be built console.log("Packages scheduled to be built", this.packagesToBeBuilt); - + this.childs = DependencyHelper.getChildsOfAllPackages( this.project_directory, @@ -164,7 +166,7 @@ export default class BuildImpl { `----------------------------------------------------------------------------------------------------` ); - + return this.generatedPackages; } @@ -279,12 +281,16 @@ export default class BuildImpl { private getPriorityandTypeOfAPackage(pkg: string) { let priority = 0; let type = ManifestHelpers.getPackageType(this.projectConfig, pkg); - if (type == "Unlocked") { + if (type === "Unlocked") { if (this.childs[pkg] > 0) priority = PRIORITY_UNLOCKED_PKG_WITH_DEPENDENCY; else priority = PRIORITY_UNLOCKED_PKG_WITHOUT_DEPENDENCY; - } else { + } else if (type === "Source") { priority = PRIORITY_SOURCE_PKG; + } else if (type === "Data") { + priority = PRIORITY_DATA_PKG; + } else { + throw new Error(`Unknown package type ${type}`); } return { priority, type }; @@ -352,7 +358,7 @@ export default class BuildImpl { console.log(`Package creation initiated for ${sfdx_package}`); let result; - if (packageType == "Unlocked") { + if (packageType === "Unlocked") { result = this.createUnlockedPackage( sfdx_package, commit_id, @@ -362,12 +368,20 @@ export default class BuildImpl { wait_time, isSkipValidation ); - } else { + } else if (packageType === "Source") { result = this.createSourcePackage( sfdx_package, commit_id, repository_url ); + } else if (packageType == "Data") { + result = this.createDataPackage( + sfdx_package, + commit_id, + repository_url + ); + } else { + throw new Error(`Unknown package type ${packageType}`) } return result; @@ -433,7 +447,6 @@ export default class BuildImpl { apextestsuite: null, }; - //Convert to MDAPI let createSourcePackageImpl = new CreateSourcePackageImpl( this.project_directory, sfdx_package, @@ -444,4 +457,39 @@ export default class BuildImpl { return result; } + + private createDataPackage( + sfdx_package: string, + commit_id: string, + repository_url: string + ): Promise { + let incrementedVersionNumber; + if (this.buildNumber) { + let incrementBuildNumber = new IncrementProjectBuildNumberImpl( + this.project_directory, + sfdx_package, + "BuildNumber", + false, + this.buildNumber + ); + incrementedVersionNumber = incrementBuildNumber.exec(); + } + + let packageMetadata: PackageMetadata = { + package_name: sfdx_package, + sourceVersion: commit_id, + package_version_number: incrementedVersionNumber?.versionNumber, + repository_url: repository_url, + package_type: "data" + }; + + let createDataPackageImpl = new CreateDataPackageImpl( + this.project_directory, + sfdx_package, + packageMetadata + ); + let result = createDataPackageImpl.exec(); + + return result; + } } diff --git a/packages/core/src/sfdxwrappers/CreateDataPackageImpl.ts b/packages/core/src/sfdxwrappers/CreateDataPackageImpl.ts index 3282f253b..e41e65901 100644 --- a/packages/core/src/sfdxwrappers/CreateDataPackageImpl.ts +++ b/packages/core/src/sfdxwrappers/CreateDataPackageImpl.ts @@ -2,24 +2,48 @@ import PackageMetadata from "../PackageMetadata"; import SourcePackageGenerator from "../generators/SourcePackageGenerator"; import ManifestHelpers from "../manifest/ManifestHelpers"; import MDAPIPackageGenerator from "../generators/MDAPIPackageGenerator"; +import SFPLogger from "../utils/SFPLogger"; +import { Logger,configure } from "log4js"; export default class CreateDataPackageImpl { + + private packageLogger:Logger; + public constructor( private projectDirectory: string, private sfdx_package: string, private packageArtifactMetadata: PackageMetadata - ) {} + ) { + let configuration = { + appenders: { + fileLogger: { + type: 'file', + filename: `.sfpowerscripts/logs/${sfdx_package}`, + layout: { + type: 'pattern', + pattern: '%r %m%n'}, + flags:'w' + } + }, + categories: { + default: { appenders: ['fileLogger'], level: 'all' } + } + }; + this.packageLogger= configure(configuration).getLogger(); + } public async exec(): Promise { this.packageArtifactMetadata.package_type = "data"; - console.log( - "--------------Create Data Package---------------------------" + SFPLogger.log( + "--------------Create Data Package---------------------------", + null, + this.packageLogger ); - console.log("Project Directory", this.projectDirectory); - console.log("sfdx_package", this.sfdx_package); - console.log("packageArtifactMetadata", this.packageArtifactMetadata); + SFPLogger.log("Project Directory", this.projectDirectory, this.packageLogger); + SFPLogger.log("sfdx_package", this.sfdx_package, this.packageLogger); + SFPLogger.log("packageArtifactMetadata", this.packageArtifactMetadata, this.packageLogger); let startTime = Date.now(); @@ -63,15 +87,21 @@ export default class CreateDataPackageImpl { } private printEmptyArtifactWarning() { - console.log( - "---------------------WARNING! Empty aritfact encountered-------------------------------" + SFPLogger.log( + "---------------------WARNING! Empty aritfact encountered-------------------------------", + null, + this.packageLogger ); - console.log( - "Either this folder is empty or the application of .forceignore results in an empty folder" + SFPLogger.log( + "Either this folder is empty or the application of .forceignore results in an empty folder", + null, + this.packageLogger ); - console.log("Proceeding to create an empty artifact"); - console.log( - "---------------------------------------------------------------------------------------" + SFPLogger.log("Proceeding to create an empty artifact", null, this.packageLogger); + SFPLogger.log( + "---------------------------------------------------------------------------------------", + null, + this.packageLogger ); } } diff --git a/packages/sfpowerscripts-cli/src/commands/sfpowerscripts/CreateDataPackage.ts b/packages/sfpowerscripts-cli/src/commands/sfpowerscripts/CreateDataPackage.ts index ba25a9e6f..8dd380b8c 100644 --- a/packages/sfpowerscripts-cli/src/commands/sfpowerscripts/CreateDataPackage.ts +++ b/packages/sfpowerscripts-cli/src/commands/sfpowerscripts/CreateDataPackage.ts @@ -76,11 +76,10 @@ export default class CreateDataPackage extends SfpowerscriptsCommand { package_name: sfdx_package, package_version_number: version_number, sourceVersion: commit_id, - repository_url:repository_url, - apextestsuite: null + repository_url:repository_url }; - fs.writeFileSync(`test.json`, JSON.stringify(packageMetadata, null, 4)); - //Convert to MDAPI + + let createDataPackageImpl = new CreateDataPackageImpl( null, sfdx_package, @@ -94,14 +93,14 @@ export default class CreateDataPackage extends SfpowerscriptsCommand { //Generate Artifact let artifact = await ArtifactGenerator.generateArtifact(sfdx_package,process.cwd(),artifactDirectory,packageMetadata); - console.log(`Created source package ${sfdx_package}_sfpowerscripts_artifact`); + console.log(`Created data package ${sfdx_package}_sfpowerscripts_artifact`); if (this.flags.gittag) { exec(`git config --global user.email "sfpowerscripts@dxscale"`); exec(`git config --global user.name "sfpowerscripts"`); let tagname = `${sfdx_package}_v${version_number}`; console.log(`Creating tag ${tagname}`); - exec(`git tag -a -m "${sfdx_package} Source Package ${version_number}" ${tagname} HEAD`, {silent:false}); + exec(`git tag -a -m "${sfdx_package} Data Package ${version_number}" ${tagname} HEAD`, {silent:false}); } console.log("\nOutput variables:"); diff --git a/packages/sfpowerscripts-cli/src/commands/sfpowerscripts/CreateSourcePackage.ts b/packages/sfpowerscripts-cli/src/commands/sfpowerscripts/CreateSourcePackage.ts index be23d6b36..34700e6ba 100644 --- a/packages/sfpowerscripts-cli/src/commands/sfpowerscripts/CreateSourcePackage.ts +++ b/packages/sfpowerscripts-cli/src/commands/sfpowerscripts/CreateSourcePackage.ts @@ -81,8 +81,7 @@ export default class CreateSourcePackage extends SfpowerscriptsCommand { package_version_number: version_number, sourceVersion: commit_id, repository_url:repository_url, - package_type:"source", - apextestsuite: null + package_type:"source" }; //Convert to MDAPI From 1d4e9a3af7357e15da96b8323ea069198ff109d3 Mon Sep 17 00:00:00 2001 From: Azlam <43767972+azlam-abdulsalam@users.noreply.github.com> Date: Thu, 15 Oct 2020 11:46:24 +1100 Subject: [PATCH 6/8] Update versions for develop pipeline --- build_templates/azpipelines-dev.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build_templates/azpipelines-dev.yml b/build_templates/azpipelines-dev.yml index 39e2bad48..daf52727c 100644 --- a/build_templates/azpipelines-dev.yml +++ b/build_templates/azpipelines-dev.yml @@ -1,11 +1,11 @@ -name: Milestone17$(Rev:.r) +name: Milestone18$(Rev:.r) variables: - group: Tokens - name: major - value: 17 + value: 18 - name: minor value: $[counter(variables['major'], 200)] @@ -57,4 +57,4 @@ stages: displayName: 'Install the new version of the plugin' inputs: script: | - az devops extension install --extension-id sfpowerscripts-dev --publisher-id AzlamSalam --org https://dev.azure.com/safebot \ No newline at end of file + az devops extension install --extension-id sfpowerscripts-dev --publisher-id AzlamSalam --org https://dev.azure.com/safebot From 417cf582f762d9cc919441366f22907982ab62e1 Mon Sep 17 00:00:00 2001 From: Azlam <43767972+azlam-abdulsalam@users.noreply.github.com> Date: Thu, 15 Oct 2020 11:54:48 +1100 Subject: [PATCH 7/8] Update dependency to new version of core --- .../azpipelines/BuildTasks/CreateDataPackageTask/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/azpipelines/BuildTasks/CreateDataPackageTask/package.json b/packages/azpipelines/BuildTasks/CreateDataPackageTask/package.json index f978bb021..39c2aa49c 100644 --- a/packages/azpipelines/BuildTasks/CreateDataPackageTask/package.json +++ b/packages/azpipelines/BuildTasks/CreateDataPackageTask/package.json @@ -9,7 +9,7 @@ }, "license": "MIT", "dependencies": { - "@dxatscale/sfpowerscripts.core": "^2.1.6", + "@dxatscale/sfpowerscripts.core": "^3.0.0", "azure-pipelines-task-lib": "^2.8.0" } } From 7bbd0ab3ae4130debaed78a872365d24666bdad1 Mon Sep 17 00:00:00 2001 From: Alan Ly Date: Thu, 15 Oct 2020 12:06:03 +1100 Subject: [PATCH 8/8] Update core version in InstallDataPackage task --- .../azpipelines/BuildTasks/InstallDataPackageTask/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/azpipelines/BuildTasks/InstallDataPackageTask/package.json b/packages/azpipelines/BuildTasks/InstallDataPackageTask/package.json index e34021167..80587e51e 100644 --- a/packages/azpipelines/BuildTasks/InstallDataPackageTask/package.json +++ b/packages/azpipelines/BuildTasks/InstallDataPackageTask/package.json @@ -9,7 +9,7 @@ }, "license": "MIT", "dependencies": { - "@dxatscale/sfpowerscripts.core": "^2.1.6", + "@dxatscale/sfpowerscripts.core": "^3.0.0", "azure-devops-node-api": "^10.1.1", "azure-pipelines-task-lib": "^2.8.0" }