Skip to content
Merged
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
39 changes: 39 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Test

on:
release:
types: [published]
pull_request:
branches:
- master
push:
branches:
- master

env:
NODE_VERSION: "22.x"

jobs:
test:
name: Test
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v5

- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: npm
cache-dependency-path: "**/package-lock.json"

- name: Install dependencies
run: npm ci

- name: Run linter
run: npm run lint

- name: Run tests
run: npm test
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## 5.2.1

- Moved CLI to a separate module.
- Prefixed Node modules with `node:`.
- Updated README.md.
- Added GitHub test workflow.

## 5.1.1

- Added file system exclusions.
Expand Down
72 changes: 46 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
aemsync
=======
# aemsync


The code and content synchronization for Sling / AEM (Adobe Experience Manager).

### Synopsis
## Synopsis

The tool pushes content to AEM instance(s) upon a file change.

Expand All @@ -12,21 +12,22 @@ The tool pushes content to AEM instance(s) upon a file change.
* IDE / editor agnostic.
* Works on Windows, Linux, and Mac.

### Installation
## Installation

With [npm](http://npmjs.org) do:

```
npm install aemsync -g
```

### Usage
## Usage

Simply run `aemsync` on your project path, make a change to any of your files or directories, and watch the magic happen.

### Advanced usage
## Advanced usage

### CLI

CLI
```
Usage:
aemsync [OPTIONS]
Expand Down Expand Up @@ -66,49 +67,68 @@ Website:
https://github.com/gavoja/aemsync
```

JavaScript API
```JavaScript
import { aemsync, push } from 'aemsync'
### API

Watch mode:

// Interactive watch example.
const args = { workingDir }
```js
import { aemsync } from 'aemsync'

const args = { workingDir: 'c:/code/my-aem-project' }

for await (const result of aemsync(args)) {
console.log(result)
}
```

Push:

// Push example.
const args = { payload: [
'./foo/bar/my-workspace/jcr_content/apps/my-app/components/my-component',
'./foo/bar/my-workspace/jcr_content/apps/my-app/components/something-else'
]}
```js
import { push } from 'aemsync'

const result = (await push(args).next()).value
console.log(result)
const args = {
payload: [
'./foo/bar/my-workspace/jcr_content/apps/my-app/components/my-component',
'./foo/bar/my-workspace/jcr_content/apps/my-app/components/something-else'
]
}

// Will yield for each target.
for await (const result of push(args)) {
console.log(result)
}
```

JavaScript's arguments and defaults for `aemsync()` and `push()` functions:
Defaults for `args`:

```JavaScript
```js
const args = {
workingDir: '.',
exclude: ['**/jcr_root/*', '**/@(.git|.svn|.hg|target)', '**/@(.git|.svn|.hg|target)/**'],
exclude: [
// AEM root folders (we do not want to accidentally delete them).
'**/jcr_root/*',
// Special files.
'**/@(.*|target|[Tt]humbs.db|[Dd]esktop.ini)',
// Special folders.
'**/@(.*|target)/**'
],
packmgrPath: '/crx/packmgr/service.jsp',
targets: ['http://admin:admin@localhost:4501'],
targets: ['http://admin:admin@localhost:4502'],
delay: 300,
checkIfUp: false
checkIfUp: false,
verbose: false
}
```

### Description
## Description

Watching for file changes is fast, since it uses Node's `recursive` option for `fs.watch()` where applicable.

Any changes inside `jcr_root` folders are detected and uploaded to AEM instance(s) as a package. By default, there is a simple exclusion filter in place to prevent hidden or system files from being uploaded. It also ignores changes to first-level directories under `jcr_root` in order to prevent accidental removal of `apps`, `libs`, or any other first-level node in AEM. The exclusion filter can be overridden with the `-e` parameter.

The delay is the time elapsed since the last change before the package is created. In case of bulk changes (e.g., switching between code branches), creating a new package per file should be avoided; instead, all changes should be pushed in one go. Lowering the value decreases the delay for a single file change but may increase the delay for multiple file changes. If you are unsure, please leave it at the default.

### Caveats
## Caveats

1. Packages are installed using the package manager service (`/crx/packmgr/service.jsp`), which takes some time to initialize after AEM startup. If the push happens before initialization, the Sling Post Servlet will take over, causing the `/crx/packmgr/service.jsp/file` node to be added to the repository. Use the `-c` option to perform a status check before sending (all bundles must be active).
2. Changing any XML file will cause the parent folder to be pushed. Given the many special cases around XML files, the handling is left to the package manager.
3 changes: 0 additions & 3 deletions bin/aemsync.js

This file was deleted.

10 changes: 5 additions & 5 deletions package-lock.json

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

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
"type": "git",
"url": "https://github.com/gavoja/aemsync.git"
},
"main": "src/index.js",
"main": "src/api.js",
"devDependencies": {
"dotenv": "^17.2.1",
"dotenv": "^17.2.2",
"dotenv-cli": "^10.0.0",
"fs-extra": "^11.3.1",
"release-it": "^19.0.4",
Expand All @@ -33,7 +33,7 @@
"xml-to-json-stream": "^1.1.0"
},
"scripts": {
"start": "node ./bin/aemsync.js",
"start": "node ./src/cli.js",
"lint": "npx standard",
"format": "npx standard --fix",
"test": "node --test --test-reporter=spec --test-reporter-destination=stdout --experimental-test-coverage --test-coverage-exclude \"test/**/*\"",
Expand All @@ -42,10 +42,10 @@
"release:dry": "dotenv release-it --dry-run"
},
"engines": {
"node": ">=16.16.0"
"node": ">=22.18.0"
},
"bin": {
"aemsync": "./bin/aemsync.js"
"aemsync": "./src/cli.js"
},
"license": "MIT",
"false": {}
Expand Down
Loading