Skip to content

Commit

Permalink
Add better docs to --scanRoutes (#338)
Browse files Browse the repository at this point in the history
* feat(scully): better docs on `--scanRoutes`

add some more explanation on scan

ISSUES CLOSED: #336

* Update traverseAppRoutesPlugin.ts
  • Loading branch information
SanderElias authored Mar 1, 2020
1 parent e9587f8 commit 6ff4a4e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
6 changes: 6 additions & 0 deletions docs/scully-cmd-line.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Scully CLI has the following options available:
- [proxyConfig](proxyconfig)
- [removeStaticDist](#removestaticdist)
- [open](#open)
- [scanRoutes](scanRoutes)
- [ssl](#ssl)
- [ssl-cert](#ssl-cert)
- [ssl-key](#ssl-key)
Expand Down Expand Up @@ -94,6 +95,11 @@ npx scully serve/watch --open

Alias `--o`. Open the default browser and show the scully dist.

## scanRoutes

Alias `--sr` or `--scan`
Scan the application again to find unhandled routes. This normally only done once. When you add/change routes in the app, you need this parameter to discover the new routes.

## ssl

```bash
Expand Down
6 changes: 5 additions & 1 deletion scully/routerPlugins/traverseAppRoutesPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ export const traverseAppRoutes = async (appRootFolder = scullyConfig.projectRoot
if (scanRoutes === false && existFolder(routesPath)) {
try {
const result = JSON.parse(readFileSync(routesPath).toString()) as string[];
log('Using stored unhandled routes');
logWarn(`
----------------------------------
Using stored unhandled routes!.
To discover new routes in the angular app use "${yellow('npm run scully -- --scanRoutes')}"
----------------------------------`);
return result;
} catch {}
}
Expand Down
1 change: 1 addition & 0 deletions scully/utils/cli-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ export const {showBrowser, path, port, folder, sge, configFileName, project, bas
.boolean('sr')
.default('sr', false)
.alias('sr', 'scanRoutes')
.alias('sr', 'scan')
.describe('sr', 'Scan the app for unhandled routes')
/** baseFilter */
.string('bf')
Expand Down
12 changes: 9 additions & 3 deletions scully/watchMode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,17 +92,23 @@ let wss;
async function enableLiveReloadServer() {
await loadConfig;
try {
console.log('enable reload on port', scullyConfig.reloadPort);
wss = new Server({port: scullyConfig.reloadPort});
log('enable reload on port', scullyConfig.reloadPort);
// tslint:disable-next-line:only-arrow-functions
wss = new Server({port: scullyConfig.reloadPort, noServer: true});
wss.on('connection', client => {
client.on('message', message => {
// console.log(`Received message => ${message}`);
});
client.send('Hello! Message From Server!!');
});
} catch (e) {
console.error(e);
logError(`
-----------------------------------
The port "${yellow(scullyConfig.reloadPort)}" is not available for the live-reload server.
live reload will not be available. You can configure a different port in the config file.
-----------------------------------`);
}
wss = undefined;
}

if (!cliOptions.noWatch && !cliOptions.serve) {
Expand Down

0 comments on commit 6ff4a4e

Please sign in to comment.