Skip to content

Commit 01c9395

Browse files
SanderEliasVillanuevand
authored andcommitted
feat(scully): add warnings
* feat(compileconfig.ts): throw a warning whthrow warning when config file is not found * feat(defaultaction.ts): throw a warning and terminates when no routes are found
1 parent 10ec043 commit 01c9395

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

scully/utils/compileConfig.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {join} from 'path';
33
import * as yargs from 'yargs';
44
import {ScullyConfig} from '..';
55
import {angularRoot, scullyConfig} from './config';
6+
import { logWarn, yellow } from './log';
67

78
export const {configFile: configFileName} = yargs
89
.string('cf')
@@ -15,6 +16,7 @@ export const compileConfig = async (): Promise<ScullyConfig> => {
1516
const path = join(angularRoot, configFileName);
1617
if (!(await pathExists(path))) {
1718
/** no ts config, nothing to do. */
19+
logWarn(`Config file "${yellow(path)}" not found, only rendering normal routes`)
1820
return ({} as unknown) as ScullyConfig;
1921
}
2022
const {config} = await import(path);

scully/utils/defaultAction.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {storeRoutes} from '../systemPlugins/storeRoutes';
66
import {writeToFs} from '../systemPlugins/writeToFs.plugin';
77
import {updateScullyConfig, loadConfig} from './config';
88
import {ScullyConfig} from './interfacesandenums';
9-
import {log} from './log';
9+
import {log, logWarn} from './log';
1010
import {cpus} from 'os';
1111
import {asyncPool} from './asyncPool';
1212
import {chunk} from './chunk';
@@ -19,6 +19,10 @@ export const generateAll = async (config?: Partial<ScullyConfig>) => {
1919
try {
2020
log('Finding all routes in application.');
2121
const appRouteArray = await traverseAppRoutes();
22+
if (appRouteArray.length<1) {
23+
logWarn('No routes found in application, are you sure you installed the router? Terminating.')
24+
process.exit(15);
25+
}
2226
log('Pull in data to create additional routes.');
2327
const dataRoutes = await addOptionalRoutes(appRouteArray);
2428
await storeRoutes(dataRoutes);

0 commit comments

Comments
 (0)