diff --git a/CHANGELOG.md b/CHANGELOG.md index 334f30a..dd49646 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # aemfed changelog +## 0.0.4 + +* Update BrowserSync to fix issue with reloading all css [#1505](https://github.com/BrowserSync/browser-sync/issues/1505). It introduces a problem with Firefix and the web console however. +* Add option to specify start port for BrowserSync proxy, so it is easier to run multiple versions at the same time + ## 0.0.3 * Fix exception when specific files or a directory were removed diff --git a/package-lock.json b/package-lock.json index 7a40e0e..3e77e12 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1172,6 +1172,11 @@ "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=" }, + "decode-html": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/decode-html/-/decode-html-2.0.0.tgz", + "integrity": "sha1-fQqIfORCgOYJeKcH67f4CB/WHqo=" + }, "decode-uri-component": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.0.tgz", diff --git a/package.json b/package.json index 7317468..f8c1980 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "aemsync": "abmaonline/aemsync#338c091", "browser-sync": "^2.24.4", "chalk": "^2.4.1", + "decode-html": "^2.0.0", "graceful-fs": "^4.1.9", "less-tree": "abmaonline/less-tree#6168498", "minimist": "^1.2.0", diff --git a/src/bs-wrapper.ts b/src/bs-wrapper.ts index 9a54ba5..7ec05c7 100644 --- a/src/bs-wrapper.ts +++ b/src/bs-wrapper.ts @@ -10,6 +10,7 @@ import { StyleTrees } from "./style-trees"; export interface IWrapperConfig { bsOptions: browserSync.Options; jcrContentRoots: string[]; + proxyPort: number; servers: string[]; dumpLibsPath?: string; } @@ -37,7 +38,6 @@ interface ITracerSettings { } const instances: { [key: string]: Instance } = {}; -const port = 3000; // TODO make configurable let styleTrees: StyleTrees; let config: IWrapperConfig; @@ -303,7 +303,7 @@ export function create(args: IWrapperConfig): Promise { clientlibTree: new ClientlibTree({ name, server }), name, online: true, - port: port + index * 2, // Claim numbers for proxy and ui + port: args.proxyPort + index * 2, // Claim numbers for proxy and ui server }; instances[host] = instance; @@ -320,21 +320,30 @@ export function create(args: IWrapperConfig): Promise { promisesState.push( setSlingTracerSettings(instance) .then(sameInstance => { - const tracerEnabled = - instance.aemSettings.tracer && - instance.aemSettings.tracer.enabled && - instance.aemSettings.tracer.servletEnabled; - if (!tracerEnabled) { + if (instance.aemSettings.tracer) { + const tracerEnabled = + instance.aemSettings.tracer.enabled && + instance.aemSettings.tracer.servletEnabled; + if (!tracerEnabled) { + console.log( + chalk`[{blue ${ + instance.name + }}] {cyan Apache Sling Log Tracer is not enabled, so errors from compiling and minifying Less and Javascript by AEM cannot be shown. To enable it, go to [{yellow /system/console/configMgr}], search for 'Apache Sling Log Tracer' and turn on both 'Enabled' and 'Recording Servlet Enabled}'.` + ); + } + } else { console.log( chalk`[{blue ${ instance.name - }}] {cyan Apache Sling Log Tracer is not enabled, so errors from compiling and minifying Less and Javascript by AEM cannot be shown. To enable it, go to [{yellow /system/console/configMgr}], search for 'Apache Sling Log Tracer' and turn on both 'Enabled' and 'Recording Servlet Enabled}'.` + }}] {cyan Apache Sling Log Tracer config was not found, so probably not supported in this version of AEM}.` ); } }) .catch(err => { console.error( - chalk`[{blue ${instance.name}}] Something went wrong:`, + chalk`[{blue ${ + instance.name + }}] [{red ERROR}] Something went wrong:`, err ); }) diff --git a/src/index.ts b/src/index.ts index 1c3c372..cf44615 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,6 @@ import { Pipeline, Watcher } from "aemsync"; import chalk from "chalk"; +import decode from "decode-html"; import gfs from "graceful-fs"; import minimist from "minimist"; import opn from "opn"; @@ -15,6 +16,7 @@ function separate() { const MSG_HELP = `Usage: aemfed [OPTIONS] Options: -t targets Default is http://admin:admin@localhost:4502 + -p proxy_port Default is 3000 -w path_to_watch Default is current -e exclude_filter Anymatch exclude filter; disabled by default -i sync_interval Update interval in milliseconds; default is 100 @@ -32,7 +34,9 @@ function reloadBrowser( if (!error) { bsWrapper.reload(host, inputList); } else { - console.error(host + ": Error when pushing pack: ", error); + console.error( + chalk`[{blue ${host}}] [{red Error}] when pushing pack: ${decode(error)}` + ); } } @@ -71,7 +75,8 @@ export function init(): void { // TODO make some sort of defaults file and get defaults from there (and use in all modules) const targets: string = args.t || "http://admin:admin@localhost:4502"; - const pushInterval: number = args.i || 100; + const proxyPort: number = parseInt(args.p, 10) || 3000; + const pushInterval: number = parseInt(args.i, 10) || 100; const exclude: string = args.e || ""; const startPage: string = args.o || "false"; const startBrowser: string = args.browser || "google chrome"; @@ -79,6 +84,7 @@ export function init(): void { separate(); console.log("Working dirs:", workingDirs); console.log("Targets:", targets); + console.log("Proxy port:", proxyPort); console.log("Interval:", pushInterval); console.log("Exclude:", exclude); separate(); @@ -116,6 +122,7 @@ export function init(): void { ] }, jcrContentRoots: workingDirs, + proxyPort, servers: targetList }); diff --git a/src/types/decode-html.d.ts b/src/types/decode-html.d.ts new file mode 100644 index 0000000..070893c --- /dev/null +++ b/src/types/decode-html.d.ts @@ -0,0 +1 @@ +export default function decode(html: string): string;