Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 54 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,11 @@ agility sync [options]

**Operation Control Options:**

| Option | Type | Default | Description |
| ------------- | ------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
| `--update` | boolean | `false` | Download fresh data from source instance before operations, if left false, incremental sync is performed to only get changed data. |
| `--overwrite` | boolean | `false` | Force update existing items in target instance instead of creating new items with -1 IDs. Default: false (Warning: may cause duplicate items in lists, overwriting existing content) |
| Option | Type | Default | Description |
| ---------------- | ------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
| `--update` | boolean | `false` | Download fresh data from source instance before operations, if left false, incremental sync is performed to only get changed data. |
| `--overwrite` | boolean | `false` | Force update existing items in target instance instead of creating new items with -1 IDs. Default: false (Warning: may cause duplicate items in lists, overwriting existing content) |
| `--autoPublish` | string | _(disabled)_ | Automatically publish synced items that were published in the source instance. Values: `content`, `pages`, `both`. If flag is provided without a value, defaults to `both`. Items that are only in staging (not published) in the source are skipped. |

**UI & Output Options:**

Expand Down Expand Up @@ -141,10 +142,59 @@ agility sync --sourceGuid="abc123" --targetGuid="def456" --models="BlogPost,Blog

# Sync models with dependencies (includes content, assets, galleries, containers, lists, but not pages)
agility sync --sourceGuid="abc123" --targetGuid="def456" --models-with-deps="BlogPost,BlogCategory"

# Sync and auto-publish everything that was published in source
agility sync --sourceGuid="abc123" --targetGuid="def456" --autoPublish

# Sync and auto-publish only content (not pages)
agility sync --sourceGuid="abc123" --targetGuid="def456" --autoPublish=content

# Sync and auto-publish only pages
agility sync --sourceGuid="abc123" --targetGuid="def456" --autoPublish=pages
```
---
## Advanced Topics

### Auto-Publish

The `--autoPublish` flag lets you automatically publish synced content and/or pages in the target instance immediately after a sync completes. Only items that are **published in the source instance** will be published in the target — staging-only items are skipped.

#### Modes

| Value | Behavior |
| --------- | --------------------------------------------- |
| `both` | Publish both content items and pages (default when flag is provided without a value) |
| `content` | Publish only content items |
| `pages` | Publish only pages |

#### How It Works

1. During sync, the CLI tracks which content items and pages were successfully pushed to the target instance
2. It also checks the publish state of each item in the source — only items with a published state are eligible
3. After all sync operations complete, the CLI publishes the eligible items in the target using the batch workflow API
4. Publishing is done per-locale to match the workflow API requirements
5. After publishing, reference mappings are updated to reflect the new published versions

#### Examples

```bash
# Auto-publish everything (content + pages) — flag without value defaults to 'both'
agility sync --sourceGuid="abc123" --targetGuid="def456" --autoPublish

# Explicitly publish both
agility sync --sourceGuid="abc123" --targetGuid="def456" --autoPublish=both

# Publish only content items (skip pages)
agility sync --sourceGuid="abc123" --targetGuid="def456" --autoPublish=content

# Publish only pages (skip content)
agility sync --sourceGuid="abc123" --targetGuid="def456" --autoPublish=pages
```

> **Note:** Auto-publish only works with `sync` operations (not `pull`). Items that fail to sync will not be published. Any publish errors are reported in the final summary alongside sync errors.

---

### Model-Specific Sync

The CLI provides two options for selective synchronization based on specific content models: `--models` and `--models-with-deps`. This is particularly useful for large instances where you only want to sync certain content types.
Expand Down
13 changes: 11 additions & 2 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
testMatch: ['**/src/tests/**/*.ts'],
testPathIgnorePatterns: ['/node_modules/', '/dist/', '/src/index.ts'],
// Default: unit tests only (exclude integration tests)
testMatch: ['**/src/tests/**/*.test.ts'],
testPathIgnorePatterns: ['/node_modules/', '/dist/', '/src/index.ts', 'integration\\.test\\.ts'],
setupFilesAfterEnv: ['<rootDir>/src/tests/setup.ts'],
// Map TypeScript path aliases to actual paths
moduleNameMapper: {
'^core/(.*)$': '<rootDir>/src/core/$1',
'^core$': '<rootDir>/src/core',
'^lib/(.*)$': '<rootDir>/src/lib/$1',
'^types/(.*)$': '<rootDir>/src/types/$1',
},
};
19 changes: 10 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@agility/cli",
"version": "1.0.0",
"version": "1.0.0-beta.13.4",
"description": "Agility CLI for working with your content. (Public Beta)",
"repository": {
"type": "git",
Expand All @@ -17,6 +17,8 @@
"postbuild": "chmod +x dist/index.js",
"refresh": "rm -rf ./node_modules ./package-lock.json && npm install",
"test": "jest",
"test:unit": "jest",
"test:integration": "jest --testMatch=\"**/*.integration.test.ts\" --testPathIgnorePatterns=\"/node_modules/|/dist/|/src/index.ts\"",
"debug": "node --inspect-brk -r ts-node/register src/index.ts"
},
"keywords": [
Expand Down Expand Up @@ -45,12 +47,13 @@
"dependencies": {
"@agility/content-fetch": "^2.0.10",
"@agility/content-sync": "^1.2.0",
"@agility/management-sdk": "^0.1.35",
"@agility/management-sdk": "^0.1.38",
"ansi-colors": "^4.1.3",
"blessed": "^0.1.81",
"blessed-contrib": "^4.11.0",
"cli-progress": "^3.11.2",
"date-fns": "^4.1.0",
"form-data": "^4.0.5",
"fuzzy": "^0.1.3",
"inquirer": "^8.0.0",
"inquirer-checkbox-plus-prompt": "^1.4.2",
Expand Down
Loading