diff --git a/README.md b/README.md index 3c447e8..7bbd8c1 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,6 @@ aemsync -t targets -w path_to_watch -e: Anymatch exclude filter; any file matching the pattern will be skipped. -d: Enable debug mode. ``` - ``` aemsync -t http://admin:admin@localhost:4502,http://admin:admin@localhost:4503 -w ~/workspace/my_project ``` @@ -53,29 +52,26 @@ let onPushEnd = (err, host) => { if (err) { return console.log(`Error when pushing package to ${host}.`, err) } - console.log(`Package pushed to ${host}.`) + console.log(`Package pushed to ${host}.`) } -// Create Pusher and Watcher. -let pusher = new Pusher(targets, pushInterval, onPushEnd) -let watcher = new Watcher() - -// Initialize queue processing. -pusher.start() - -// Watch over workingDir. -watcher.watch(workingDir, exclude, (localPath) => { - // Add item to Pusher's queue when a change is detected. - pusher.enqueue(localPath) -}) +aemsync({workingDir, targets, exclude, pushInterval, onPushEnd}) ``` ### Description -The Watcher uses Node's `fs.watch()` function to watch over directory changes recursively. For Windows and OSX the `recursive` option is used, which significantly improves the performance. Any changes inside `jcr_root/*` folders are detected and deployed to AEM instance(s) as a package. +The Watcher uses Node's `fs.watch()` function to watch over directory changes recursively. For Windows and OSX the `recursive` option is used, which significantly improves the performance. +Any changes inside `jcr_root` folders are detected and deployed to AEM instance(s) as a package. Rules: +* Changes to first level folders under `jcr_root` are igored. This is to avoid accidentally removing `apps`, `libs` or any other first level folders in AEM. +* The following are ignored by default: `.svn`, `.git`, `.hg`. Update interval is the time the Pusher waits for file changes before the package is created. In case of multiple file changes (e.g. switching between code branches), creating a new package per file should be avoided and 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 the default value. +Note that some of the file changes will result in pushing the entire parent folder: +* Ading, removing or renaming files or directories. +* Changing `.content.xml`. +* Changing any file or directory inside `nt:unstructured` subtree. In this case the first non `nt:unstructured` ancestor will be pushed. This behaviour ensures proper handling of self-contained unstructured blocks of nodes such as dialogs that are distributed across multiple files (see [issue 19](https://github.com/gavoja/aemsync/issues/19)). + ### Known issues Packages are installed using package manager service (`/crx/packmgr/service.jsp`), which takes some time to initialize after AEM startup. If the push happens before, the Sling Post Servlet will take over causing the `/crx/packmgr/service.jsp/file` node to be added to the repository. diff --git a/index.js b/index.js index 5df0d4c..b240d4c 100644 --- a/index.js +++ b/index.js @@ -3,23 +3,33 @@ const minimist = require('minimist') const path = require('path') const fs = require('graceful-fs') -const log = require('./src/log.js') +const log = require('./src/log') const chalk = require('chalk') -const Watcher = require('./src/watcher.js') -const Pusher = require('./src/pusher.js') +const Watcher = require('./src/watcher') +const Pusher = require('./src/pusher') + +const MSG_HELP = `Usage: aemsync [OPTIONS] + +Options: + -t targets Defult is http://admin:admin@localhost:4502 + -w path_to_watch Default is current + -e exclude_filter Micromatch exclude filter; disabled by default + -i sync_interval Update interval; default is 300ms + -d Enable debug mode + -h Displays this screen -const MSG_HELP = `Usage: aemsync [OPTIONS] - -Options: - -t targets Defult is http://admin:admin@localhost:4502 - -w path_to_watch Default is current - -e exclude_filter Anymach exclude filter; disabled by default - -i sync_interval Update interval; default is 300ms - -d Enable debug mode - -h Displays this screen - Website: https://github.com/gavoja/aemsync` +function aemsync (args) { + let pusher = new Pusher(args.targets.split(','), args.pushInterval, args.onPushEnd) + let watcher = new Watcher() + + pusher.start() + watcher.watch(args.workingDir, args.exclude, (localPath) => { + pusher.enqueue(localPath) + }) +} + function main () { let args = minimist(process.argv.slice(2)) @@ -42,28 +52,20 @@ function main () { let pushInterval = args.i ? args.i : 300 let exclude = args.e ? args.e : '' - log.info(` - Working dir: ${chalk.yellow(workingDir)} - Targets: ${chalk.yellow(targets)} - Interval: ${chalk.yellow(pushInterval)} - Exclude: ${chalk.yellow(exclude)} + log.info(` + Working dir: ${chalk.yellow(workingDir)} + Targets: ${chalk.yellow(targets)} + Interval: ${chalk.yellow(pushInterval)} + Exclude: ${chalk.yellow(exclude)} `) - let pusher = new Pusher(targets.split(','), pushInterval) - let watcher = new Watcher() - - pusher.start() - watcher.watch(workingDir, exclude, (localPath) => { - pusher.enqueue(localPath) - }) + aemsync({workingDir, targets, pushInterval, exclude}) } if (require.main === module) { main() } -module.exports = { - main: main, - Watcher: Watcher, - Pusher: Pusher -} +aemsync.Watcher = Watcher +aemsync.Pusher = Pusher +module.exports = aemsync diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..3ff84c9 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,806 @@ +{ + "name": "aemsync", + "version": "2.0.0", + "lockfileVersion": 1, + "dependencies": { + "ansi-regex": { + "version": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.0.0.tgz", + "integrity": "sha1-xQYbbg74qBd15Q9dZhUb9r83EQc=" + }, + "ansi-styles": { + "version": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", + "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=" + }, + "archiver": { + "version": "https://registry.npmjs.org/archiver/-/archiver-0.21.0.tgz", + "integrity": "sha1-Ep2gyOrhqb8IoBLYpOIEOh4pCc4=" + }, + "archiver-utils": { + "version": "https://registry.npmjs.org/archiver-utils/-/archiver-utils-0.3.0.tgz", + "integrity": "sha1-nYU0CJL+nnxsGxtq88M2ks9ZW3A=" + }, + "arr-union": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/arr-union/-/arr-union-3.1.0.tgz", + "integrity": "sha1-45sJrqne+Gao8gbiiK9jkZuuOcQ=" + }, + "async": { + "version": "https://registry.npmjs.org/async/-/async-1.5.2.tgz", + "integrity": "sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo=" + }, + "atob": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/atob/-/atob-2.0.3.tgz", + "integrity": "sha1-GcenYEc3dEaPILLS0DNyrX1Mv10=" + }, + "balanced-match": { + "version": "https://registry.npmjs.org/balanced-match/-/balanced-match-0.3.0.tgz", + "integrity": "sha1-qRzdHr7xqGZZ5w/03vAWJfwtZ1Y=" + }, + "base": { + "version": "0.11.1", + "resolved": "https://registry.npmjs.org/base/-/base-0.11.1.tgz", + "integrity": "sha1-s2p/ERE4U6NCoVaR2Y4tzIpswnA=", + "dependencies": { + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=" + }, + "is-descriptor": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.5.tgz", + "integrity": "sha1-4/uLSrZfOjc3M4jhi0AdeMWMvqc=" + }, + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" + }, + "isobject": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz", + "integrity": "sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk=" + } + } + }, + "bl": { + "version": "https://registry.npmjs.org/bl/-/bl-1.1.2.tgz", + "integrity": "sha1-/cqHGplxOqANGeO7ukHER4emU5g=" + }, + "brace-expansion": { + "version": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.3.tgz", + "integrity": "sha1-Rr/1ARXUf8mriYVKu4fZgHihCZE=" + }, + "buffer-crc32": { + "version": "https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.5.tgz", + "integrity": "sha1-2wA6wmceYuvW7OeOosLhtAVzbpE=" + }, + "cache-base": { + "version": "0.8.5", + "resolved": "https://registry.npmjs.org/cache-base/-/cache-base-0.8.5.tgz", + "integrity": "sha1-YM6zUEAh7O7HAR/TOEt/TpVym/o=", + "dependencies": { + "isobject": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.0.tgz", + "integrity": "sha1-OVZSF/NmF4nooKDAgNX35rxG4aA=" + } + } + }, + "chalk": { + "version": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=" + }, + "class-utils": { + "version": "0.3.5", + "resolved": "https://registry.npmjs.org/class-utils/-/class-utils-0.3.5.tgz", + "integrity": "sha1-F+eTEDdQ+WJ7IXbqNM/RtWWQPIA=", + "dependencies": { + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=" + }, + "is-descriptor": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.5.tgz", + "integrity": "sha1-4/uLSrZfOjc3M4jhi0AdeMWMvqc=" + }, + "isobject": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.0.tgz", + "integrity": "sha1-OVZSF/NmF4nooKDAgNX35rxG4aA=" + } + } + }, + "collection-visit": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/collection-visit/-/collection-visit-0.2.3.tgz", + "integrity": "sha1-L2JIPK7MlfCDuaRUo+6eYTmteVc=" + }, + "combined-stream": { + "version": "https://registry.npmjs.org/combined-stream/-/combined-stream-0.0.7.tgz", + "integrity": "sha1-ATfmV7qlp1QcV6w3rF/AfXO03B8=" + }, + "component-emitter": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.2.1.tgz", + "integrity": "sha1-E3kY1teCg/ffemt8WmPhQOaUJeY=" + }, + "compress-commons": { + "version": "https://registry.npmjs.org/compress-commons/-/compress-commons-0.4.2.tgz", + "integrity": "sha1-GghHSJ8NcT0N12NDwMLQVdyc2JI=" + }, + "concat-map": { + "version": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" + }, + "copy-descriptor": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/copy-descriptor/-/copy-descriptor-0.1.1.tgz", + "integrity": "sha1-Z29us8OZl8LuGsOpJP1hJHSPV40=" + }, + "core-util-is": { + "version": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" + }, + "crc32-stream": { + "version": "https://registry.npmjs.org/crc32-stream/-/crc32-stream-0.4.0.tgz", + "integrity": "sha1-tU1Mbu/TW1PmU9BiswbtxjFq4m0=" + }, + "debug": { + "version": "2.6.8", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.8.tgz", + "integrity": "sha1-5zFTHKLt4n0YgiJCfaF4IdaP9Pw=" + }, + "define-property": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", + "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=" + }, + "delayed-stream": { + "version": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-0.0.5.tgz", + "integrity": "sha1-1LH0OpPoKW3+AmlPRoC8N6MTxz8=" + }, + "end-of-stream": { + "version": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.1.0.tgz", + "integrity": "sha1-6TUyWLqpEIll78QcsO+K3i88+wc=" + }, + "escape-string-regexp": { + "version": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=" + }, + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=" + }, + "form-data": { + "version": "https://registry.npmjs.org/form-data/-/form-data-0.2.0.tgz", + "integrity": "sha1-Jvi8JtpkQOKZy9z7aQNcT3em5GY=", + "dependencies": { + "async": { + "version": "https://registry.npmjs.org/async/-/async-0.9.2.tgz", + "integrity": "sha1-rqdNXmHB+JlhO/ZL2mbUx48v0X0=" + } + } + }, + "fragment-cache": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/fragment-cache/-/fragment-cache-0.2.1.tgz", + "integrity": "sha1-QpD60n8T6Jvn8zeZxrxaCr//DRk=" + }, + "get-value": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/get-value/-/get-value-2.0.6.tgz", + "integrity": "sha1-3BXKHGcjh8p2vTesCjlbogQqLCg=" + }, + "glob": { + "version": "https://registry.npmjs.org/glob/-/glob-6.0.4.tgz", + "integrity": "sha1-DwiGD2oVUSey+t1PnOJLGqtuTSI=" + }, + "graceful-fs": { + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", + "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=" + }, + "has-ansi": { + "version": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", + "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=" + }, + "has-value": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/has-value/-/has-value-0.3.1.tgz", + "integrity": "sha1-ex9YutpiyoJ+wKIHgCVlSEWZXh8=" + }, + "has-values": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/has-values/-/has-values-0.1.4.tgz", + "integrity": "sha1-bWHeldkd/Km5oCCJrThL/49it3E=" + }, + "inflight": { + "version": "https://registry.npmjs.org/inflight/-/inflight-1.0.4.tgz", + "integrity": "sha1-bLtFIevVHODsCpNr/XZX736bFyo=" + }, + "inherits": { + "version": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz", + "integrity": "sha1-sX0I0ya0Qj5Wjv9xn5GwscvfafE=" + }, + "is-accessor-descriptor": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", + "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=" + }, + "is-buffer": { + "version": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.3.tgz", + "integrity": "sha1-24l/w/esotUN6UtsjCiWpHcWJ68=" + }, + "is-data-descriptor": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", + "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=" + }, + "is-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.0.tgz", + "integrity": "sha1-1uxobyOPawLyN1er4Sz2suonkPk=" + }, + "is-extendable": { + "version": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", + "integrity": "sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik=" + }, + "is-odd": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-odd/-/is-odd-1.0.0.tgz", + "integrity": "sha1-O4qTLrAos3dcObsJ6RdnrM22kIg=", + "dependencies": { + "is-number": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", + "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=" + } + } + }, + "is-plain-object": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.3.tgz", + "integrity": "sha1-wVvz5LZrYtcu+vKSWEhmPsvGGbY=", + "dependencies": { + "isobject": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.0.tgz", + "integrity": "sha1-OVZSF/NmF4nooKDAgNX35rxG4aA=" + } + } + }, + "isarray": { + "version": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=" + }, + "isobject": { + "version": "https://registry.npmjs.org/isobject/-/isobject-2.0.0.tgz", + "integrity": "sha1-II3ocr1zeMKpKvlCij9W65GhIsQ=" + }, + "kind-of": { + "version": "https://registry.npmjs.org/kind-of/-/kind-of-3.0.2.tgz", + "integrity": "sha1-GH20JwRufpCUVpLmdoZovWkA3qA=" + }, + "lazy-cache": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/lazy-cache/-/lazy-cache-2.0.2.tgz", + "integrity": "sha1-uRkKT5EzVGlIQIWfio9whNiCImQ=" + }, + "lazystream": { + "version": "https://registry.npmjs.org/lazystream/-/lazystream-0.1.0.tgz", + "integrity": "sha1-GyXWPHcqTCDwpe0KnXf0hLbhaSA=", + "dependencies": { + "readable-stream": { + "version": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.33.tgz", + "integrity": "sha1-OjYN1mwbHX/UcFOJhg7aHQ9hEmw=" + } + } + }, + "lodash": { + "version": "https://registry.npmjs.org/lodash/-/lodash-3.10.1.tgz", + "integrity": "sha1-W/Rejkm6QYnhfUgnid/RW9FAt7Y=" + }, + "map-cache": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/map-cache/-/map-cache-0.2.2.tgz", + "integrity": "sha1-wyq9C9ZSXZsFFkW7TyasXcmKDb8=" + }, + "map-visit": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/map-visit/-/map-visit-0.1.5.tgz", + "integrity": "sha1-2+Q5J85VJbgN/BVzpE1oxR8mgWs=" + }, + "micromatch": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.0.3.tgz", + "integrity": "sha512-uTjtugrI0sC0KbJNLZtCmyrg5oFESH++4QqLUdHLrKugDbCz+9V5983YfjpfJhmxqf5f2H+JV9JJhS0brPS9TA==", + "dependencies": { + "arr-diff": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", + "integrity": "sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA=" + }, + "arr-flatten": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.0.3.tgz", + "integrity": "sha1-onTthawIhJtr14R8RYB0XcUa37E=" + }, + "array-unique": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz", + "integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=" + }, + "braces": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-2.2.2.tgz", + "integrity": "sha1-JB+GjCsmkNn+vu5afIP7vyXQCxs=" + }, + "expand-brackets": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-2.1.4.tgz", + "integrity": "sha1-t3c14xXOMPa27/D4OwQVGiJEliI=", + "dependencies": { + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=" + } + } + }, + "extglob": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/extglob/-/extglob-1.1.0.tgz", + "integrity": "sha1-Bni04s5FwOTlD15er7Gw2rW05CQ=", + "dependencies": { + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=" + }, + "to-regex": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/to-regex/-/to-regex-2.1.0.tgz", + "integrity": "sha1-4606QM/hGVWaBa6kPkyu+sxekB0=", + "dependencies": { + "regex-not": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/regex-not/-/regex-not-0.1.2.tgz", + "integrity": "sha1-vH8cSUSxGINT0H3uuRK5TgreJds=" + } + } + } + } + }, + "fill-range": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz", + "integrity": "sha1-1USBHUKPmOsGpj3EAtJAPDKMOPc=" + }, + "is-buffer": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.5.tgz", + "integrity": "sha1-Hzsm72E7IUuIy8ojzGwB2Hlh7sw=" + }, + "is-descriptor": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.5.tgz", + "integrity": "sha1-4/uLSrZfOjc3M4jhi0AdeMWMvqc=", + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=" + } + } + }, + "is-number": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", + "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=" + } + } + }, + "isobject": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.0.tgz", + "integrity": "sha1-OVZSF/NmF4nooKDAgNX35rxG4aA=" + }, + "kind-of": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-4.0.0.tgz", + "integrity": "sha1-IIE989cSkosgc3hpGkUGb65y3Vc=" + }, + "repeat-string": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz", + "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=" + } + } + }, + "mime-db": { + "version": "https://registry.npmjs.org/mime-db/-/mime-db-1.12.0.tgz", + "integrity": "sha1-PQxjGA9FjrENMlqqN9fFiuMS6dc=" + }, + "mime-types": { + "version": "https://registry.npmjs.org/mime-types/-/mime-types-2.0.14.tgz", + "integrity": "sha1-MQ4VnbI+B3+Lsit0jav6SVcUCqY=" + }, + "minimatch": { + "version": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.0.tgz", + "integrity": "sha1-UjYVelHk8ATBd/s8Un/33Xjw74M=" + }, + "minimist": { + "version": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" + }, + "mixin-deep": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.2.0.tgz", + "integrity": "sha1-0CuMb4ttS49ZgtP9AJxJGYUcP+I=", + "dependencies": { + "for-in": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz", + "integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=" + } + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + }, + "nanomatch": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.0.tgz", + "integrity": "sha1-dv2z1K52F+N3GeekBHuECFfAyxw=", + "dependencies": { + "arr-diff": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", + "integrity": "sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA=" + }, + "array-unique": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz", + "integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=" + }, + "is-buffer": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.5.tgz", + "integrity": "sha1-Hzsm72E7IUuIy8ojzGwB2Hlh7sw=" + }, + "is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=" + }, + "kind-of": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-4.0.0.tgz", + "integrity": "sha1-IIE989cSkosgc3hpGkUGb65y3Vc=" + } + } + }, + "node-int64": { + "version": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz", + "integrity": "sha1-h6kGXNs1XTGC2PlM4RGIuCXGijs=" + }, + "normalize-path": { + "version": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.0.1.tgz", + "integrity": "sha1-R4hqwWYnYNQmG32XnSQXCdPOP3o=" + }, + "object-copy": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/object-copy/-/object-copy-0.1.0.tgz", + "integrity": "sha1-fn2Fi3gb18mRpBupde04EnVOmYw=", + "dependencies": { + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=" + }, + "is-buffer": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.5.tgz", + "integrity": "sha1-Hzsm72E7IUuIy8ojzGwB2Hlh7sw=" + }, + "is-descriptor": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.5.tgz", + "integrity": "sha1-4/uLSrZfOjc3M4jhi0AdeMWMvqc=" + }, + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=" + } + } + }, + "object-visit": { + "version": "0.3.4", + "resolved": "https://registry.npmjs.org/object-visit/-/object-visit-0.3.4.tgz", + "integrity": "sha1-rhXPhvCy/dVRdxY2RIRSxUw9qCk=" + }, + "object.pick": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/object.pick/-/object.pick-1.2.0.tgz", + "integrity": "sha1-tTkr7peC2m2ft9avr1OXefEjTCs=", + "dependencies": { + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" + }, + "isobject": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz", + "integrity": "sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk=" + } + } + }, + "once": { + "version": "https://registry.npmjs.org/once/-/once-1.3.3.tgz", + "integrity": "sha1-suJhVXzkwxTsgwTz+oJmPkKXyiA=" + }, + "pascalcase": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/pascalcase/-/pascalcase-0.1.1.tgz", + "integrity": "sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ=" + }, + "path-is-absolute": { + "version": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.0.tgz", + "integrity": "sha1-Jj2tpmqz8vsQv3+dJN2PPlcO+RI=" + }, + "posix-character-classes": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/posix-character-classes/-/posix-character-classes-0.1.1.tgz", + "integrity": "sha1-AerA/jta9xoqbAL+q7jB/vfgDqs=" + }, + "process-nextick-args": { + "version": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.6.tgz", + "integrity": "sha1-D5awAc6pCxJZLOVm7bl+wR5pvQU=" + }, + "readable-stream": { + "version": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.0.5.tgz", + "integrity": "sha1-okJvjc1FUcd6M/lu3yiGojyClmk=" + }, + "regex-not": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/regex-not/-/regex-not-1.0.0.tgz", + "integrity": "sha1-Qvg+OXcWIt+CawKvF2Ul1qXxV/k=" + }, + "repeat-element": { + "version": "https://registry.npmjs.org/repeat-element/-/repeat-element-1.1.2.tgz", + "integrity": "sha1-7wiaF40Ug7quTZPrmLT55OEdmQo=" + }, + "resolve-url": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/resolve-url/-/resolve-url-0.2.1.tgz", + "integrity": "sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo=" + }, + "set-getter": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/set-getter/-/set-getter-0.1.0.tgz", + "integrity": "sha1-12nBgsnVpR9AkUXy+6guXoboA3Y=" + }, + "set-value": { + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/set-value/-/set-value-0.4.3.tgz", + "integrity": "sha1-fbCPnT0i3H945Trzw79GZuzfzPE=" + }, + "simple-watcher": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/simple-watcher/-/simple-watcher-3.0.0.tgz", + "integrity": "sha1-xFjxoobbRoKC85S+po0MaFHoLcA=" + }, + "snapdragon": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/snapdragon/-/snapdragon-0.8.1.tgz", + "integrity": "sha1-4StUh/re0+PeoKyR6UAL91tAE3A=", + "dependencies": { + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=" + }, + "is-descriptor": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.5.tgz", + "integrity": "sha1-4/uLSrZfOjc3M4jhi0AdeMWMvqc=" + } + } + }, + "snapdragon-node": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/snapdragon-node/-/snapdragon-node-2.0.1.tgz", + "integrity": "sha1-O0hc7yptVd+utSZBqDiMbqgcvqI=", + "dependencies": { + "isobject": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.0.tgz", + "integrity": "sha1-OVZSF/NmF4nooKDAgNX35rxG4aA=" + } + } + }, + "snapdragon-util": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/snapdragon-util/-/snapdragon-util-3.0.0.tgz", + "integrity": "sha1-CsYojYQJ5F0E/RA04Lt0VwHK6cA=", + "dependencies": { + "is-buffer": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.5.tgz", + "integrity": "sha1-Hzsm72E7IUuIy8ojzGwB2Hlh7sw=" + }, + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=" + } + } + }, + "source-map": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.6.tgz", + "integrity": "sha1-dc449SvwczxafwwRjYEzSiu19BI=" + }, + "source-map-resolve": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/source-map-resolve/-/source-map-resolve-0.5.0.tgz", + "integrity": "sha1-/K0LZLcK+ydpnkJZUMtevNQQvCA=" + }, + "source-map-url": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/source-map-url/-/source-map-url-0.4.0.tgz", + "integrity": "sha1-PpNdfd1zYxuXZZlW1VEo6HtQhKM=" + }, + "split-string": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/split-string/-/split-string-2.1.1.tgz", + "integrity": "sha1-r0sG2CFWBCZEbDzZMc2mGJQNN9A=" + }, + "static-extend": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/static-extend/-/static-extend-0.1.2.tgz", + "integrity": "sha1-YICcOcv/VTNyJv1eC1IPNB8ftcY=", + "dependencies": { + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=" + }, + "is-descriptor": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.5.tgz", + "integrity": "sha1-4/uLSrZfOjc3M4jhi0AdeMWMvqc=" + } + } + }, + "string_decoder": { + "version": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=" + }, + "strip-ansi": { + "version": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=" + }, + "supports-color": { + "version": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", + "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=" + }, + "tar-stream": { + "version": "https://registry.npmjs.org/tar-stream/-/tar-stream-1.3.2.tgz", + "integrity": "sha1-ck0atIAcmzFJzep2X+jJDqcfZgY=" + }, + "to-object-path": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/to-object-path/-/to-object-path-0.3.0.tgz", + "integrity": "sha1-KXWIt7Dn4KwI4E5nL4XB9JmeF68=" + }, + "to-regex": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/to-regex/-/to-regex-3.0.1.tgz", + "integrity": "sha1-FTWL7kosg712N3uh3ASdDxiDeq4=", + "dependencies": { + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=" + }, + "is-descriptor": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.5.tgz", + "integrity": "sha1-4/uLSrZfOjc3M4jhi0AdeMWMvqc=" + } + } + }, + "to-regex-range": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-2.1.1.tgz", + "integrity": "sha1-fIDBe53+vlmeJzZ+DU3VWQFB2zg=", + "dependencies": { + "is-number": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", + "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=" + }, + "repeat-string": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz", + "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=" + } + } + }, + "union-value": { + "version": "0.2.4", + "resolved": "https://registry.npmjs.org/union-value/-/union-value-0.2.4.tgz", + "integrity": "sha1-c3UVJ4ZnkFfns3qmdug0aPwCdPA=" + }, + "unset-value": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/unset-value/-/unset-value-0.1.2.tgz", + "integrity": "sha1-UGgQuGfyfCpabpsEgzYx9t5Y0xA=", + "dependencies": { + "isobject": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.0.tgz", + "integrity": "sha1-OVZSF/NmF4nooKDAgNX35rxG4aA=" + } + } + }, + "urix": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/urix/-/urix-0.1.0.tgz", + "integrity": "sha1-2pN/emLiH+wf0Y1Js1wpNQZ6bHI=" + }, + "use": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/use/-/use-2.0.2.tgz", + "integrity": "sha1-riig1y+TvyJCKhii43mZMRLeyOg=", + "dependencies": { + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=" + }, + "is-descriptor": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.5.tgz", + "integrity": "sha1-4/uLSrZfOjc3M4jhi0AdeMWMvqc=" + }, + "isobject": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.0.tgz", + "integrity": "sha1-OVZSF/NmF4nooKDAgNX35rxG4aA=" + } + } + }, + "util-deprecate": { + "version": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" + }, + "wrappy": { + "version": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.1.tgz", + "integrity": "sha1-HmWWmWXMvC20VIxrhKbyxa7dRzk=" + }, + "xtend": { + "version": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", + "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=" + }, + "zip-stream": { + "version": "https://registry.npmjs.org/zip-stream/-/zip-stream-0.8.0.tgz", + "integrity": "sha1-I2sv4lgjy09I6DNvW/p0OqWunb0=" + } + } +} diff --git a/package.json b/package.json index e690d0a..8b09c05 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "aemsync", - "version": "1.1.1", + "version": "2.0.0", "description": "Adobe AEM Synchronization Tool", "author": "Michal Kochel ", "keywords": [ @@ -19,16 +19,17 @@ }, "main": "index.js", "dependencies": { - "anymatch": "^1.3.0", "archiver": "^0.21.0", - "chalk": "^1.1.1", + "chalk": "^1.1.3", "form-data": "^0.2.0", - "graceful-fs": "^4.1.3", + "graceful-fs": "^4.1.11", + "micromatch": "^3.0.3", "minimist": "^1.2.0", - "simple-watcher": "^1.0.1" + "simple-watcher": "^3.0.0" }, "bin": { "aemsync": "./bin/aemsync" }, - "license": "MIT" + "license": "MIT", + "false": {} } diff --git a/src/handlers/content-handler.js b/src/handlers/content-handler.js index afff22f..cf56fc4 100644 --- a/src/handlers/content-handler.js +++ b/src/handlers/content-handler.js @@ -2,28 +2,28 @@ const path = require('path') -const RE_DOT = /^.*\/\..*$/ const RE_CONTENT_PATH = /^.*\/jcr_root(\/[^\/]+){2,}$/ const RE_SPECIAL = /^.*\/(_jcr_content|[^\/]+\.dir|\.content\.xml).*$/ -const RE_TARGET_PATH = /^.*\/target\/(.*\/)?jcr_root\/.*$/ +const RE_TARGET_PATH = /^.*\/(target|\..*)\/(.*\/)?jcr_root\/.*$/ +const IGNORED = ['.svn', '.hg', '.git'] class ContentHandler { process (localPath) { let cleanPath = localPath.replace(/\\/g, '/') // TODO: Simplify path checking. - // Ignore dot-prefixed files and directories except ".content.xml". - if (cleanPath.match(RE_DOT) && !cleanPath.endsWith('.content.xml')) { + // Ignore CVS files. + if (IGNORED.some(i => cleanPath.endsWith(i))) { return null } - // Process items only under 'jcr_root/*/' - if (!cleanPath.match(RE_CONTENT_PATH)) { + // Skip paths on 'target' or dot prefixed folders + if (cleanPath.match(RE_TARGET_PATH)) { return null } - // Skip paths on 'target' - if (cleanPath.match(RE_TARGET_PATH)) { + // Process items only under 'jcr_root/*/' + if (!cleanPath.match(RE_CONTENT_PATH)) { return null } diff --git a/src/package.js b/src/package.js index b3d0695..ac6185f 100644 --- a/src/package.js +++ b/src/package.js @@ -10,52 +10,52 @@ const CONTENT_XML = '.content.xml' const DATA_PATH = path.resolve(__dirname, '..', 'data') const PACKAGE_CONTENT_PATH = path.join(DATA_PATH, 'package_content') const NT_FOLDER_PATH = path.join(DATA_PATH, 'nt_folder', '.content.xml') -const RE_UNSTRUCTURED = /jcr:primaryType\s*=\s*"nt:unstructured"/g -const RE_CONTENT_PATH = /^.*\/jcr_root(\/[^\/]+){2,}$/ -const FILTER_ZIP_PATH = 'META-INF/vault/filter.xml' -const FILTER_WRAPPER = ` -%s +const RE_UNSTRUCTURED = /jcr:primaryType\s*=\s*"nt:unstructured"/g +const RE_CONTENT_PATH = /^.*\/jcr_root(\/[^\/]+){2,}$/ +const FILTER_ZIP_PATH = 'META-INF/vault/filter.xml' +const FILTER_WRAPPER = ` +%s ` -const FILTER = ` +const FILTER = ` ` -const FILTER_CHILDREN = ` - - - - - ` - -class Package { +const FILTER_CHILDREN = ` + + + + + ` + +class Package { constructor () { this.items = [] this.path = [] - } - - /** Gets item with metadata from local path. */ - getItem (localPath) { - let item = { - localPath: localPath - } - - try { - let stat = fs.statSync(localPath) - item.exists = true - item.isDirectory = stat.isDirectory() - } catch (err) { - item.exists = false - } - - return item - } - - /** Adds local path to package. */ - add (localPath) { - return this.addItem(this.getItem(localPath)) - } - - /** Adds item to package. */ - addItem (item) { - // Handle duplicates. + } + + /** Gets item with metadata from local path. */ + getItem (localPath) { + let item = { + localPath: localPath + } + + try { + let stat = fs.statSync(localPath) + item.exists = true + item.isDirectory = stat.isDirectory() + } catch (err) { + item.exists = false + } + + return item + } + + /** Adds local path to package. */ + add (localPath) { + return this.addItem(this.getItem(localPath)) + } + + /** Adds item to package. */ + addItem (item) { + // Handle duplicates. for (let i = this.items.length - 1; i >= 0; --i) { let existingItem = this.items[i] @@ -71,41 +71,41 @@ class Package { this.items.splice(i, 1) } } - - item.zipPath = item.zipPath || this.getZipPath(item.localPath) - item.filterPath = item.filterPath || this.getFilterPath(item.zipPath) - this.items.push(item) - - this.handleContentXml(item) - - return item - } - - /** Adds all '.content.xml' files on the item's path. */ - handleContentXml (item) { - // Skip if '.content.xml' file. - if (path.basename(item.localPath) === CONTENT_XML) { - return - } - - // Add all '.content.xml' files going up the path. - let dirPath = path.dirname(item.localPath) - while (this.cleanPath(dirPath).match(RE_CONTENT_PATH)) { - let contentXmlPath = path.join(dirPath, CONTENT_XML) - let contents = this.getFileContents(contentXmlPath) - // Process parent if 'nt:unstructured' found. - if (contents && contents.match(RE_UNSTRUCTURED)) { - return this.addItem(this.getItem(dirPath)) - } - - // Process '.content.xml'. - if (contents) { - this.addItem(this.getItem(contentXmlPath)) - } - - dirPath = path.dirname(dirPath) - } - } + + item.zipPath = item.zipPath || this.getZipPath(item.localPath) + item.filterPath = item.filterPath || this.getFilterPath(item.zipPath) + this.items.push(item) + + return this.handleContentXml(item) + } + + /** Adds all '.content.xml' files on the item's path. */ + handleContentXml (item) { + // Skip if '.content.xml' file. + if (path.basename(item.localPath) === CONTENT_XML) { + return item + } + + // Add all '.content.xml' files going up the path. + let dirPath = path.dirname(item.localPath) + while (this.cleanPath(dirPath).match(RE_CONTENT_PATH)) { + let contentXmlPath = path.join(dirPath, CONTENT_XML) + let contents = this.getFileContents(contentXmlPath) + // Process parent if 'nt:unstructured' found. + if (contents && contents.match(RE_UNSTRUCTURED)) { + return this.addItem(this.getItem(dirPath)) + } + + // Process '.content.xml'. + if (contents) { + this.addItem(this.getItem(contentXmlPath)) + } + + dirPath = path.dirname(dirPath) + } + + return item + } /** Saves package. */ save (callback) { diff --git a/src/pusher.js b/src/pusher.js index 1693767..976b8c6 100644 --- a/src/pusher.js +++ b/src/pusher.js @@ -77,7 +77,6 @@ class Pusher { } } - try { // Add all paths to the package. let pack = new Package() diff --git a/src/watcher.js b/src/watcher.js index c80770e..9481c37 100644 --- a/src/watcher.js +++ b/src/watcher.js @@ -1,7 +1,7 @@ 'use strict' const log = require('./log.js') -const anymatch = require('anymatch') +const mm = require('micromatch') const chalk = require('chalk') const watcher = require('simple-watcher') @@ -13,7 +13,7 @@ class Watcher { log.debug('Changed:', localPath) // Skip excluded. - if (exclude && anymatch(exclude, localPath)) { + if (exclude && mm(exclude, localPath)) { return }