Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jschonning/w 14245254 #205

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
35 changes: 21 additions & 14 deletions DEV.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
OmniStudio Migration Tool
=========================
# OmniStudio Migration Tool

This repository contains the code required to enable the OmniStudio Migration Tool SFDX plugin.

Expand All @@ -9,7 +8,8 @@ This repository contains the code required to enable the OmniStudio Migration To
2. Authenticate your SFDX cli into the org you are going to use for development. You can follow authentication steps [here](https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_auth_web.htm).
3. Clone this repository into your local machine.
4. Open the migration tool code folder in VSCode or your prefered editor.
5. In a new command line tool, run the following command:
5. In a new command line tool, run the following command:

```
bin/run omnistudio:migration:migrate -u [email protected] --namespace=agarciana46_238 --json
```
Expand All @@ -18,7 +18,7 @@ bin/run omnistudio:migration:migrate -u [email protected]

```
USAGE
$ sfdx omnistudio:migration:migrate [-n <string>] [-f] [-v <string>] [-u <string>] [--apiversion <string>] [--json] [--loglevel
$ sfdx omnistudio:migration:migrate [-n <string>] [-f] [-v <string>] [-u <string>] [--apiversion <string>] [--json] [--loglevel
trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]

OPTIONS
Expand All @@ -38,11 +38,14 @@ OPTIONS
--loglevel=(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL) [default: warn] logging level for
this command invocation

-a, --allversions migrate all versions

```

### Folder structure

```
-
-
- .vscode VSCode configuration folder
- bin Tools required to run in developer mode
- messages JSON files with user messages used in the plugin
Expand All @@ -53,31 +56,35 @@ OPTIONS
- utils Utilities (network, debugging, logging, etc.)
```



_See code: [src/commands/hello/org.ts](https://github.com/agarcia-sf/omnistudio-migration-tool/blob/v0.0.0/src/commands/hello/org.ts)_

<!-- commandsstop -->
<!-- debugging-your-plugin -->

# Debugging your plugin

We recommend using the Visual Studio Code (VS Code) IDE for your plugin development. Included in the `.vscode` directory of this plugin is a `launch.json` config file, which allows you to attach a debugger to the node process when running your commands.

To debug the `hello:org` command:
To debug the `hello:org` command:

1. Start the inspector

If you linked your plugin to the sfdx cli, call your command with the `dev-suspend` switch:

If you linked your plugin to the sfdx cli, call your command with the `dev-suspend` switch:

```sh-session
$ sfdx hello:org -u [email protected] --dev-suspend
```

Alternatively, to call your command using the `bin/run` script, set the `NODE_OPTIONS` environment variable to `--inspect-brk` when starting the debugger:

```sh-session
$ NODE_OPTIONS=--inspect-brk bin/run hello:org -u [email protected]
```

2. Set some breakpoints in your command code
3. Click on the Debug icon in the Activity Bar on the side of VS Code to open up the Debug view.
4. In the upper left hand corner of VS Code, verify that the "Attach to Remote" launch configuration has been chosen.
5. Hit the green play button to the left of the "Attach to Remote" launch configuration window. The debugger should now be suspended on the first line of the program.
5. Hit the green play button to the left of the "Attach to Remote" launch configuration window. The debugger should now be suspended on the first line of the program.
6. Hit the green play button at the top middle of VS Code (this play button will be to the right of the play button that you clicked in step #5).
<br><img src=".images/vscodeScreenshot.png" width="480" height="278"><br>
Congrats, you are debugging!
<br><img src=".images/vscodeScreenshot.png" width="480" height="278"><br>
Congrats, you are debugging!
20 changes: 14 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
OmniStudio Migration Tool
=========================

# OmniStudio Migration Tool

### Before You Begin
1. Confirm you have an OmniStudio Admin license.
2. Enable Standard OmniStudio Runtime in Setup > OmniStudio Settings.

Read and follow the directions in the Omnistudio migration documentation: https://help.salesforce.com/s/articleView?id=sf.os_migrate_omnistudio_custom_objects_to_standard_objects.htm&type=5

## Running SFDX plugin

1. Install SFDX cli using the official documentation located [here](https://developer.salesforce.com/docs/atlas.en-us.sfdx_setup.meta/sfdx_setup/sfdx_setup_install_cli.htm).
2. Authenticate your SFDX cli into the org you are going to use for development. You can follow authentication steps [here](https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_auth_web.htm).
3. In a new terminal session, install the plugin using the following command

```
sfdx plugins:install @salesforce/plugin-omnistudio-migration-tool
```

4. To run the migration tool, run the following command from your command line tool:

```
// To migrate everything
sfdx omnistudio:migration:migrate -u [email protected] --namespace=VLOCITY_PACKAGE_NAMESPACE
Expand All @@ -24,14 +25,18 @@ sfdx omnistudio:migration:migrate -u [email protected] --namespace=VL
--only=ip
--only=os
--only=fc

//to migrate all versions of the components and not just the active ones:
--allversions
```

5. An HTML page will be open in your default browser with the results of your migration job.

### Usage & parameters

```
USAGE
$ sfdx omnistudio:migration:migrate [-n <string>] [-f] [-v <string>] [-u <string>] [--apiversion <string>] [--json] [--loglevel
$ sfdx omnistudio:migration:migrate [-n <string>] [-f] [-v <string>] [-u <string>] [--apiversion <string>] [--json] [--loglevel
trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]

OPTIONS
Expand All @@ -51,4 +56,7 @@ OPTIONS
--loglevel=(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL) [default: warn] logging level for
this command invocation

-a, --allversions migrate all versions and not
and not just the active ones.

```
27 changes: 4 additions & 23 deletions command-snapshot.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,19 @@
{
"command": "basecommand",
"plugin": "@salesforce/plugin-omnistudio-migration-tool",
"flags": [
"apiversion",
"json",
"loglevel",
"targetusername"
],
"flags": ["apiversion", "json", "loglevel", "targetusername"],
"alias": []
},
{
"command": "omnistudio:migration:info",
"plugin": "@salesforce/plugin-omnistudio-migration-tool",
"flags": [
"apiversion",
"json",
"loglevel",
"name",
"targetdevhubusername",
"targetusername"
],
"flags": ["allversions", "apiversion", "json", "loglevel", "name", "targetdevhubusername", "targetusername"],
"alias": []
},
{
"command": "omnistudio:migration:migrate",
"plugin": "@salesforce/plugin-omnistudio-migration-tool",
"flags": [
"apiversion",
"json",
"loglevel",
"namespace",
"only",
"targetusername"
],
"flags": ["allversions", "apiversion", "json", "loglevel", "namespace", "only", "targetusername"],
"alias": []
}
]
]
5 changes: 3 additions & 2 deletions messages/info.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
"examples": [
"sfdx omnistudio:migration:info --targetusername [email protected] --targetdevhubusername [email protected]",
"sfdx omnistudio:migration:info --name myname --targetusername [email protected]"
]
}
],
"allVersionsDescription": "Migrate all versions of a component"
}
5 changes: 3 additions & 2 deletions messages/migrate.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@
"errorWhileActivatingOs": "Could not activate OmniScript / Integration Procedure: ",
"errorWhileActivatingCard": "Could not activate Card: ",
"errorWhileUploadingCard": "An error ocurred while uploading Card: ",
"errorWhileCreatingElements": "An error ocurred while saving OmniScript elements: "
}
"errorWhileCreatingElements": "An error ocurred while saving OmniScript elements: ",
"allVersionsDescription": "Migrate all versions of a component"
}
11 changes: 11 additions & 0 deletions src/commands/omnistudio/migration/info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ export default class Org extends SfdxCommand {
char: 'n',
description: messages.getMessage('nameFlagDescription'),
}),
allversions: flags.boolean({
char: 'a',
description: messages.getMessage('allVersionsDescription'),
required: false,
}),
};

// Comment this out if your command does not require an org username
Expand All @@ -42,6 +47,8 @@ export default class Org extends SfdxCommand {

public async run(): Promise<AnyJson> {
const name = (this.flags.name || 'world') as string;
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const allVersions = this.flags.allversions || false;

// this.org is guaranteed because requiresUsername=true, as opposed to supportsUsername
const conn = this.org.getConnection();
Expand Down Expand Up @@ -79,6 +86,10 @@ export default class Org extends SfdxCommand {
this.ux.log(`My hub org id is: ${hubOrgId}`);
}

if (allVersions) {
outputString = `${outputString} and all versions will be migrated`;
}

// Return an object to be displayed with --json
return { orgId: this.org.getOrgId(), outputString };
}
Expand Down
40 changes: 35 additions & 5 deletions src/commands/omnistudio/migration/migrate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,19 @@ export default class Migrate extends OmniStudioBaseCommand {
char: 'o',
description: messages.getMessage('onlyFlagDescription'),
}),
allversions: flags.boolean({
char: 'a',
description: messages.getMessage('allVersionsDescription'),
required: false,
}),
};

// eslint-disable-next-line @typescript-eslint/no-explicit-any
public async run(): Promise<any> {
const namespace = (this.flags.namespace || 'vlocity_ins') as string;
const apiVersion = (this.flags.apiversion || '55.0') as string;
const migrateOnly = (this.flags.only || '') as string;
const allVersions = this.flags.allversions || false;

// this.org is guaranteed because requiresUsername=true, as opposed to supportsUsername
const conn = this.org.getConnection();
Expand All @@ -62,23 +68,47 @@ export default class Migrate extends OmniStudioBaseCommand {
if (!migrateOnly) {
migrationObjects = [
new DataRaptorMigrationTool(namespace, conn, this.logger, messages, this.ux),
new OmniScriptMigrationTool(OmniScriptExportType.All, namespace, conn, this.logger, messages, this.ux),
new CardMigrationTool(namespace, conn, this.logger, messages, this.ux),
new OmniScriptMigrationTool(
OmniScriptExportType.All,
namespace,
conn,
this.logger,
messages,
this.ux,
allVersions
),
new CardMigrationTool(namespace, conn, this.logger, messages, this.ux, allVersions),
];
} else {
switch (migrateOnly) {
case 'os':
migrationObjects.push(
new OmniScriptMigrationTool(OmniScriptExportType.OS, namespace, conn, this.logger, messages, this.ux)
new OmniScriptMigrationTool(
OmniScriptExportType.OS,
namespace,
conn,
this.logger,
messages,
this.ux,
allVersions
)
);
break;
case 'ip':
migrationObjects.push(
new OmniScriptMigrationTool(OmniScriptExportType.IP, namespace, conn, this.logger, messages, this.ux)
new OmniScriptMigrationTool(
OmniScriptExportType.IP,
namespace,
conn,
this.logger,
messages,
this.ux,
allVersions
)
);
break;
case 'fc':
migrationObjects.push(new CardMigrationTool(namespace, conn, this.logger, messages, this.ux));
migrationObjects.push(new CardMigrationTool(namespace, conn, this.logger, messages, this.ux, allVersions));
break;
case 'dr':
migrationObjects.push(new DataRaptorMigrationTool(namespace, conn, this.logger, messages, this.ux));
Expand Down
Loading