Skip to content

Commit 4445470

Browse files
authored
Initial release of OmniStudio Migration Tool (SFDX plugin)
1 parent 31bb2d2 commit 4445470

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+4357
-3094
lines changed

.circleci/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ workflows:
1111
filters:
1212
branches:
1313
ignore: main
14+
context: release
1415
- release-management/test-package:
1516
matrix:
1617
parameters:

.eslintrc.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
* Licensed under the BSD 3-Clause license.
55
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
66
*/
7+
78
module.exports = {
8-
extends: ['eslint-config-salesforce-typescript', 'eslint-config-salesforce-license'],
9+
extends: ["eslint-config-salesforce-typescript"],
10+
parser: "@typescript-eslint/parser",
911
};

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,5 @@ node_modules
3939
# os specific files
4040
.DS_Store
4141
.idea
42+
out.log
43+
migrationresults.html

.vscode/launch.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77
{
88
"type": "node",
99
"request": "attach",
10-
"name": "Attach",
10+
"name": "Attach to Remote",
11+
"address": "127.0.0.1",
1112
"port": 9229,
12-
"skipFiles": ["<node_internals>/**"]
13+
"localRoot": "${workspaceFolder}",
14+
"remoteRoot": "${workspaceFolder}"
1315
},
1416
{
1517
"name": "Run All Tests",
@@ -43,4 +45,4 @@
4345
"preLaunchTask": "Compile"
4446
}
4547
]
46-
}
48+
}

LICENSE.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2022, Salesforce.com, Inc.
1+
Copyright (c) 2018, Salesforce.com, Inc.
22
All rights reserved.
33

44
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

README.md

Lines changed: 52 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -1,117 +1,28 @@
1-
### Use the [lerna template](https://github.com/salesforcecli/lerna-template) if you need a library and plugin
1+
OmniStudio Migration Tool
2+
=========================
23

3-
### This template is useful if the library is already in another repository or the plugin is a wrapper around an API.
4+
This repository contains the code required to enable the OmniStudio Migration Tool SFDX plugin.
45

5-
# plugin-&lt;REPLACE ME&gt;
6+
## Running SFDX plugin in developer mode
67

7-
[![NPM](https://img.shields.io/npm/v/@salesforce/plugin-omnistudio-migration-tool.svg?label=@salesforce/plugin-omnistudio-migration-tool)](https://www.npmjs.com/package/@salesforce/plugin-omnistudio-migration-tool) [![CircleCI](https://circleci.com/gh/salesforcecli/plugin-omnistudio-migration-tool/tree/main.svg?style=shield)](https://circleci.com/gh/salesforcecli/plugin-omnistudio-migration-tool/tree/main) [![Downloads/week](https://img.shields.io/npm/dw/@salesforce/plugin-omnistudio-migration-tool.svg)](https://npmjs.org/package/@salesforce/plugin-omnistudio-migration-tool) [![License](https://img.shields.io/badge/License-BSD%203--Clause-brightgreen.svg)](https://raw.githubusercontent.com/salesforcecli/plugin-omnistudio-migration-tool/main/LICENSE.txt)
8-
9-
Change above to <REPLACE_ME> before finalizing
10-
11-
&lt;REPLACE ME DESCRIPTION START&gt;
12-
13-
This repository provides a template for creating a plugin for the Salesforce CLI. To convert this template to a working plugin:
14-
15-
1. Clone this repo
16-
2. Delete the .git folder
17-
3. Replace filler values
18-
a) Every instance of `<REPLACE_ME>` can be directly substitued for the name of the new plugin. However beware, things like github paths are for the salesforcecli Github organization
19-
b) Search for case-matching `REPLACE` to find other filler values, such as for the plugin description
20-
4. Use `git init` to set up the desired git information
21-
5. Follow the getting started steps below until the `sfdx hello:org` commmand is functioning
22-
23-
&lt;REPLACE ME DESCRIPTION END&gt;
24-
25-
## Learn about the plugin-omnistudio-migration-tool
26-
27-
Salesforce CLI plugins are based on the [oclif plugin framework](<(https://oclif.io/docs/introduction.html)>). Read the [plugin developer guide](https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_plugins.meta/sfdx_cli_plugins/cli_plugins_architecture_sf_cli.htm) to learn about Salesforce CLI plugin development.
28-
29-
This repository contains a lot of additional scripts and tools to help with general Salesforce node development and enforce coding standards. You should familiarize yourself with some of the [node developer packages](https://github.com/forcedotcom/sfdx-dev-packages/) used by Salesforce. There is also a default circleci config using the [release management orb](https://github.com/forcedotcom/npm-release-management-orb) standards.
30-
31-
Additionally, there are some additional tests that the Salesforce CLI will enforce if this plugin is ever bundled with the CLI. These test are included by default under the `posttest` script and it is recommended to keep these tests active in your plugin, regardless if you plan to have it bundled.
32-
33-
# Everything past here is only a suggestion as to what should be in your specific plugin's description
34-
35-
This plugin is bundled with the [Salesforce CLI](https://developer.salesforce.com/tools/sfdxcli). For more information on the CLI, read the [getting started guide](https://developer.salesforce.com/docs/atlas.en-us.sfdx_setup.meta/sfdx_setup/sfdx_setup_intro.htm).
36-
37-
We always recommend using the latest version of these commands bundled with the CLI, however, you can install a specific version or tag if needed.
38-
39-
## Install
40-
41-
```bash
42-
sfdx plugins:install <REPLACE_ME>@x.y.z
8+
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).
9+
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).
10+
3. Clone this repository into your local machine.
11+
4. Open the migration tool code folder in VSCode or your prefered editor.
12+
5. In a new command line tool, run the following command:
4313
```
44-
45-
## Issues
46-
47-
Please report any issues at https://github.com/forcedotcom/cli/issues
48-
49-
## Contributing
50-
51-
1. Please read our [Code of Conduct](CODE_OF_CONDUCT.md)
52-
2. Create a new issue before starting your project so that we can keep track of
53-
what you are trying to add/fix. That way, we can also offer suggestions or
54-
let you know if there is already an effort in progress.
55-
3. Fork this repository.
56-
4. [Build the plugin locally](#build)
57-
5. Create a _topic_ branch in your fork. Note, this step is recommended but technically not required if contributing using a fork.
58-
6. Edit the code in your fork.
59-
7. Write appropriate tests for your changes. Try to achieve at least 95% code coverage on any new code. No pull request will be accepted without unit tests.
60-
8. Sign CLA (see [CLA](#cla) below).
61-
9. Send us a pull request when you are done. We'll review your code, suggest any needed changes, and merge it in.
62-
63-
### CLA
64-
65-
External contributors will be required to sign a Contributor's License
66-
Agreement. You can do so by going to https://cla.salesforce.com/sign-cla.
67-
68-
### Build
69-
70-
To build the plugin locally, make sure to have yarn installed and run the following commands:
71-
72-
```bash
73-
# Clone the repository
74-
git clone [email protected]:salesforcecli/plugin-<REPLACE_ME>
75-
76-
# Install the dependencies and compile
77-
yarn install
78-
yarn build
79-
```
80-
81-
To use your plugin, run using the local `./bin/run` or `./bin/run.cmd` file.
82-
83-
```bash
84-
# Run using local run file.
85-
./bin/run <REPLACE_ME>
14+
bin/run omnistudio:migration:migrate -u [email protected] --namespace=agarciana46_238 --json
8615
```
8716

88-
There should be no differences when running via the Salesforce CLI or using the local run file. However, it can be useful to link the plugin to do some additional testing or run your commands from anywhere on your machine.
89-
90-
```bash
91-
# Link your plugin to the sfdx cli
92-
sfdx plugins:link .
93-
# To verify
94-
sfdx plugins
95-
```
96-
97-
## Commands
98-
99-
<!-- commands -->
100-
101-
- [`sfdx hello:org [-n <string>] [-f] [-v <string>] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`](#sfdx-helloorg--n-string--f--v-string--u-string---apiversion-string---json---loglevel-tracedebuginfowarnerrorfataltracedebuginfowarnerrorfatal)
102-
103-
## `sfdx hello:org [-n <string>] [-f] [-v <string>] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`
104-
105-
print a greeting and your org IDs
17+
### Usage & parameters
10618

10719
```
10820
USAGE
109-
$ sfdx hello:org [-n <string>] [-f] [-v <string>] [-u <string>] [--apiversion <string>] [--json] [--loglevel
21+
$ sfdx omnistudio:migration:migrate [-n <string>] [-f] [-v <string>] [-u <string>] [--apiversion <string>] [--json] [--loglevel
11022
trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]
11123
11224
OPTIONS
113-
-f, --force example boolean flag
114-
-n, --name=name name to print
25+
-n, --namespace=namespace the namespace of the vertical package
11526
11627
-u, --targetusername=targetusername username or alias for the target
11728
org; overrides default target org
@@ -127,13 +38,46 @@ OPTIONS
12738
--loglevel=(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL) [default: warn] logging level for
12839
this command invocation
12940
130-
EXAMPLES
131-
$ sfdx hello:org --targetusername [email protected] --targetdevhubusername [email protected]
132-
Hello world! This is org: MyOrg and I will be around until Tue Mar 20 2018!
133-
My hub org id is: 00Dxx000000001234
41+
```
13442

135-
$ sfdx hello:org --name myname --targetusername [email protected]
136-
Hello myname! This is org: MyOrg and I will be around until Tue Mar 20 2018!
43+
### Folder structure
44+
```
45+
-
46+
- .vscode VSCode configuration folder
47+
- bin Tools required to run in developer mode
48+
- messages JSON files with user messages used in the plugin
49+
- src
50+
- commands SFDX plugin commands
51+
- mappings A list of mappings between vertical and standard objects
52+
- migration OmniStudio Migration Tool code
53+
- utils Utilities (network, debugging, logging, etc.)
13754
```
13855

56+
57+
58+
_See code: [src/commands/hello/org.ts](https://github.com/agarcia-sf/omnistudio-migration-tool/blob/v0.0.0/src/commands/hello/org.ts)_
13959
<!-- commandsstop -->
60+
<!-- debugging-your-plugin -->
61+
# Debugging your plugin
62+
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.
63+
64+
To debug the `hello:org` command:
65+
1. Start the inspector
66+
67+
If you linked your plugin to the sfdx cli, call your command with the `dev-suspend` switch:
68+
```sh-session
69+
$ sfdx hello:org -u [email protected] --dev-suspend
70+
```
71+
72+
Alternatively, to call your command using the `bin/run` script, set the `NODE_OPTIONS` environment variable to `--inspect-brk` when starting the debugger:
73+
```sh-session
74+
$ NODE_OPTIONS=--inspect-brk bin/run hello:org -u [email protected]
75+
```
76+
77+
2. Set some breakpoints in your command code
78+
3. Click on the Debug icon in the Activity Bar on the side of VS Code to open up the Debug view.
79+
4. In the upper left hand corner of VS Code, verify that the "Attach to Remote" launch configuration has been chosen.
80+
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.
81+
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).
82+
<br><img src=".images/vscodeScreenshot.png" width="480" height="278"><br>
83+
Congrats, you are debugging!

appveyor.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
environment:
2+
nodejs_version: "10"
3+
cache:
4+
- '%LOCALAPPDATA%\Yarn -> appveyor.yml'
5+
- node_modules -> yarn.lock
6+
7+
install:
8+
- ps: Install-Product node $env:nodejs_version x64
9+
- yarn
10+
11+
build: off
12+
13+
build_script:
14+
- ps: Write-Host “Prepack plugin”
15+
- yarn prepack
16+
17+
test_script:
18+
- yarn test
19+

command-snapshot.json

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,39 @@
11
[
22
{
3-
"command": "hello:org",
3+
"command": "basecommand",
44
"plugin": "@salesforce/plugin-omnistudio-migration-tool",
5-
"flags": ["apiversion", "force", "json", "loglevel", "name", "targetdevhubusername", "targetusername"]
5+
"flags": [
6+
"apiversion",
7+
"json",
8+
"loglevel",
9+
"targetusername"
10+
],
11+
"alias": []
12+
},
13+
{
14+
"command": "omnistudio:migration:info",
15+
"plugin": "@salesforce/plugin-omnistudio-migration-tool",
16+
"flags": [
17+
"apiversion",
18+
"json",
19+
"loglevel",
20+
"name",
21+
"targetdevhubusername",
22+
"targetusername"
23+
],
24+
"alias": []
25+
},
26+
{
27+
"command": "omnistudio:migration:migrate",
28+
"plugin": "@salesforce/plugin-omnistudio-migration-tool",
29+
"flags": [
30+
"apiversion",
31+
"json",
32+
"loglevel",
33+
"namespace",
34+
"only",
35+
"targetusername"
36+
],
37+
"alias": []
638
}
7-
]
39+
]

messages/info.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"commandDescription": "print a greeting and your org IDs",
3+
"nameFlagDescription": "name to print",
4+
"forceFlagDescription": "example boolean flag",
5+
"errorNoOrgResults": "No results found for the org '%s'.",
6+
"examples": [
7+
"sfdx omnistudio:migration:info --targetusername [email protected] --targetdevhubusername [email protected]",
8+
"sfdx omnistudio:migration:info --name myname --targetusername [email protected]"
9+
]
10+
}

messages/messages.json

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)