Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions scully.config.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
/** load the plugin */
const {extraRoutesPlugin} = require('./extraPlugin/extra-plugin.js')
const {extraRoutesPlugin} = require('./extraPlugin/extra-plugin.js');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SanderElias Do you test this require in other project (plain angular)?

/** register the plugin */
registerPlugin('router', 'extra', extraRoutesPlugin);


exports.config = {
/** projectRoot is mandatory! */
projectRoot: './projects/sampleBlog/src/app',
/** outFolder is where the static distribution files end up */
outFolder: './dist/static',

routes: {
'/demo/:id': {
Expand Down
1 change: 0 additions & 1 deletion scully/scully.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ let _options = {};
spawn('node', [join(scullyConfig.homeFolder, './node_modules/.bin/scully'), 'serve'], {
detached: true,
}).on('close', err => {
console.log(err);
if (+err > 0) {
spawn(
'node',
Expand Down
13 changes: 10 additions & 3 deletions scully/utils/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {jsonc} from 'jsonc';
import {join} from 'path';
import {findAngularJsonPath} from './findAngularJsonPath';
import {ScullyConfig} from './interfacesandenums';
import {logError} from './log';
import {logError, logWarn, yellow} from './log';
import {validateConfig} from './validateConfig';
import {compileConfig} from './compileConfig';

Expand Down Expand Up @@ -45,17 +45,24 @@ const loadIt = async () => {
distFolder,
appPort: /** 1864 */ 'herodevs'.split('').reduce((sum, token) => (sum += token.charCodeAt(0)), 1000),
staticport: /** 1771 */ 'scully'.split('').reduce((sum, token) => (sum += token.charCodeAt(0)), 1000),
},
await updateScullyConfig(compiledConfig)
}
// compiledConfig
) as ScullyConfig;
await updateScullyConfig(compiledConfig);
return scullyConfig;
};
export const loadConfig = loadIt();

export const updateScullyConfig = async (config: Partial<ScullyConfig>) => {
/** note, an invalid config will abort the entire program. */
const newConfig = Object.assign({}, scullyConfig, config);
if (config.outFolder === undefined) {
logWarn(
`The option outFolder isn't configures, we are using "${yellow(scullyConfig.outFolder)} by default now"`
);
} else {
config.outFolder = join(angularRoot, config.outFolder);
}
const validatedConfig = await validateConfig(newConfig as ScullyConfig);
if (validatedConfig) {
const mergedRoutes = {...scullyConfig.routes, ...validatedConfig.routes};
Expand Down