-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/dylanyoung-dev/sitecore-cdp…
…-serializer into main
- Loading branch information
Showing
14 changed files
with
273 additions
and
147 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<!--- Provide a general summary of your changes in the Title above --> | ||
|
||
## Description / Motivation | ||
|
||
<!--- Describe your changes in detail --> | ||
<!--- Why is this change required? What problem does it solve? --> | ||
<!--- If it fixes an open issue, please link to the issue here. --> | ||
|
||
## How Has This Been Tested? | ||
|
||
<!--- Please describe in detail how you tested your changes. --> | ||
<!--- Include details of your testing environment, and the tests you ran to --> | ||
<!--- see how your change affects other areas of the code, etc. --> | ||
|
||
## Types of changes | ||
|
||
<!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: --> | ||
|
||
- [ ] Bug fix (non-breaking change which fixes an issue) | ||
- [ ] New feature (non-breaking change which adds functionality) | ||
- [ ] Breaking change (fix or feature that would cause existing functionality to change) | ||
- [ ] Documentation update (non-breaking change; modified files are limited to the `/docs` directory or other markdown files) | ||
|
||
## Checklist: | ||
|
||
<!--- Go over all the following points, and put an `x` in all the boxes that apply. --> | ||
<!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> | ||
|
||
- [ ] I have read the Contributing guide. | ||
- [ ] My code/comments/docs fully adhere to the Code of Conduct. | ||
- [ ] My change is a code change. | ||
- [ ] My change is a documentation change and there are NO other updates required. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
engine-strict=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Deploy Commands | ||
|
||
## Usage | ||
|
||
This command is useful for taking physical files and deploying them to a CDP, Personalize or CDP/Personalize tenant. Details of this command are below: | ||
|
||
| Command | Description | Parameters | | ||
| :-----: | :-------------------------------------------------- | :---------------------------------------------------- | | ||
| deploy | Command to take physical files and deploy to Tenant | --artifactPath _optional_ (defaults to `./artifacts`) | | ||
|
||
### Example | ||
|
||
```bash | ||
npx sitecore-cdp-serializer deploy | ||
``` | ||
|
||
### Notes | ||
|
||
In order to run a deploy command, you must have already run an `auth login` command to authenticate to the tenant you wish to deploy the artifacts out to. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/** | ||
* Base service for all API calls | ||
*/ | ||
|
||
import Configstore from "configstore"; | ||
import { AuthToken } from './auth/Auth.interface.js'; | ||
import fetch from 'node-fetch'; | ||
|
||
const BaseService = (config: Configstore) => { | ||
const serviceUrl = config.get('serviceUrl'); | ||
const credentials: AuthToken = config.get('credentials'); | ||
|
||
const Fetch = async(method: string, path: string, body: object | null | undefined) => { | ||
if (!serviceUrl) { | ||
throw 'Service URL not set, re-run auth command'; | ||
} | ||
|
||
if (!credentials) { | ||
throw 'You must run the auth command first to initialize the CLI'; | ||
} | ||
|
||
let data = body !== null && body !== undefined | ||
? JSON.stringify(body) | ||
: null; | ||
|
||
return await fetch(`https://${serviceUrl}/${path}`, { | ||
method, | ||
body: data, | ||
headers: { | ||
Authorization: `Bearer ${credentials.access_token}`, | ||
'Content-Type': 'application/json', | ||
}, | ||
}); | ||
} | ||
|
||
const Get = async(path: string) => { | ||
return await Fetch("get", path, null); | ||
} | ||
|
||
const Post = async(path: string, body: object | null | undefined) => { | ||
return await Fetch("post", path, body); | ||
} | ||
|
||
const Put = async(path: string, body: object | null | undefined) => { | ||
return await Fetch("put", path, body); | ||
} | ||
|
||
const Delete = async(path: string, body: object | null | undefined) => { | ||
return await Fetch("delete", path, body); | ||
} | ||
|
||
return { | ||
Fetch, | ||
Get, | ||
Post, | ||
Put, | ||
Delete, | ||
}; | ||
} | ||
|
||
export { BaseService }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.