Skip to content

Commit 7b61ffd

Browse files
authored
fix(traverseapp): looks in the different places for tsconfig.app.json (#282)
closes 279
1 parent 0e17027 commit 7b61ffd

5 files changed

Lines changed: 40 additions & 22 deletions

File tree

scully/routerPlugins/traverseAppRoutesPlugin.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {parseAngularRoutes} from 'guess-parser';
22
import {join} from 'path';
33
import * as yargs from 'yargs';
4-
import {scullyConfig, loadConfig} from '../utils/config';
4+
import {scullyConfig} from '../utils/config';
55
import {existFolder} from '../utils/fsFolder';
66
import {green, logError, logWarn, yellow} from '../utils/log';
77

@@ -18,7 +18,13 @@ export const traverseAppRoutes = async (appRootFolder = scullyConfig.projectRoot
1818
? scullyConfig.guessParserOptions.excludedFiles
1919
: [];
2020
try {
21-
const file = join(appRootFolder, 'tsconfig.app.json');
21+
let file = join(appRootFolder, 'tsconfig.app.json');
22+
if (!existFolder(file)) {
23+
file = join(appRootFolder, '../tsconfig.app.json');
24+
}
25+
if (!existFolder(file)) {
26+
file = join(appRootFolder, '../../tsconfig.app.json');
27+
}
2228
if (!existFolder(file)) {
2329
logWarn(
2430
`We could not find "${yellow(

scully/scully.ts

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
*/
66
import {readFileSync} from 'fs-extra';
77
import {join} from 'path';
8-
import * as yargs from 'yargs';
98
import './pluginManagement/systemPlugins';
109
import {startBackgroundServer} from './startBackgroundServer';
1110
import {loadConfig} from './utils/config';
@@ -16,28 +15,11 @@ import {logError, logWarn, yellow} from './utils/log';
1615
import {startScully} from './utils/startup';
1716
import {waitForServerToBeAvailable} from './utils/waitForServerToBeAvailable';
1817
import {bootServe, isBuildThere, watchMode} from './watchMode';
18+
import {watch, removeStaticDist} from './utils/cli-options';
1919

2020
/** the default of 10 is too shallow for generating pages. */
2121
require('events').defaultMaxListeners = 100;
2222

23-
const {argv: options} = yargs.option('port', {
24-
alias: 'p',
25-
type: 'number',
26-
description: 'The port to run on',
27-
});
28-
29-
const {watch} = yargs
30-
.boolean('wm')
31-
.default('wm', false)
32-
.alias('wm', 'watch')
33-
.describe('wm', 'Use this flag for use the watch mode into scully').argv;
34-
35-
const {removeStaticDist} = yargs
36-
.boolean('RSD')
37-
.default('RSD', false)
38-
.alias('RSD', 'removeStaticDist')
39-
.describe('RSD', 'Use this flag to remove the Scully outfolder before starting').argv;
40-
4123
if (process.argv.includes('version')) {
4224
const {version} = JSON.parse(readFileSync(join(__dirname, './package.json')).toString());
4325
console.log('version:', version);

scully/utils/cli-options.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import * as yargs from 'yargs';
2+
3+
export const {watch} = yargs
4+
.boolean('wm')
5+
.default('wm', false)
6+
.alias('wm', 'watch')
7+
.describe('wm', 'Use this flag for use the watch mode into scully').argv;
8+
9+
export const {removeStaticDist} = yargs
10+
.boolean('RSD')
11+
.default('RSD', false)
12+
.alias('RSD', 'removeStaticDist')
13+
.describe('RSD', 'Use this flag to remove the Scully outfolder before starting').argv;
14+
15+
export const {argv: options} = yargs.option('port', {
16+
alias: 'p',
17+
type: 'number',
18+
description: 'The port to run on',
19+
});

scully/utils/startup.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import {performance, PerformanceObserver, PerformanceObserverCallback} from 'per
22
import {generateAll} from './defaultAction';
33
import {log, yellow} from './log';
44
import {performanceIds} from './performanceIds';
5+
import {watch} from './cli-options';
6+
import {scullyConfig} from './config';
57

68
/**
79
* Starts the entire process
@@ -49,6 +51,11 @@ Generating took ${yellow(Math.floor(seconds * 100) / 100)} seconds for ${yellow(
4951
Pulling in route-data took ${logSeconds(durations.Discovery)}
5052
Rendering the pages took ${logSeconds(durations.Render)}
5153
54+
${
55+
watch
56+
? `The server is available on "${yellow(`http://${scullyConfig.hostName}:${scullyConfig.staticport}/`)}"`
57+
: ''
58+
}
5259
`);
5360
});
5461
};

scully/utils/staticServer.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,11 @@ export async function staticServer(port?: number) {
3030
scullyServer.get('/', (req, res) => res.sendFile(join(distFolder, '/index.html')));
3131

3232
scullyServerInstance = scullyServer.listen(port, scullyConfig.hostName, x => {
33-
log(`Scully static server started on "${yellow(`http://${scullyConfig.hostName}:${port}/`)}" `);
33+
log(
34+
`Scully static server started on "${yellow(
35+
`http://${scullyConfig.hostName}:${scullyConfig.staticport}/`
36+
)}"`
37+
);
3438
});
3539

3640
const angularDistServer = express();

0 commit comments

Comments
 (0)