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
873 changes: 1 addition & 872 deletions blog/page-3.md

Large diffs are not rendered by default.

3,291 changes: 65 additions & 3,226 deletions blog/page-4.adoc

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"express": "^4.17.1",
"front-matter": "^3.0.2",
"fs-extra": "^8.1.0",
"guess-parser": "^0.4.14",
"guess-parser": "^0.4.15",
"husky": "^4.0.0-beta.5",
"jasmine-core": "~3.5.0",
"jasmine-spec-reporter": "~4.2.1",
Expand Down
2 changes: 1 addition & 1 deletion projects/sampleBlog/src/app/user/user-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const routes: Routes = [
children: [
{path: '', component: PostsComponent, pathMatch: 'full'},
{path: 'friend/:friendCode', component: UserComponent},
{path: 'post/:post', component: PostComponent},
{path: 'post/:postId', component: PostComponent},
],
},
];
Expand Down
2 changes: 1 addition & 1 deletion projects/scullyio/ng-lib/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@scullyio/ng-lib",
"version": "0.0.14",
"version": "0.0.15",
"repository": {
"type": "GIT",
"url": "https://github.com/scullyio/scully/tree/master/projects/scullyio/ng-lib"
Expand Down
2 changes: 1 addition & 1 deletion schematics/scully/src/scully/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const createScullyConfig = (options: Schema) => (tree: Tree, context: SchematicC
tree.create(
scullyConfigFile,
`exports.config = {
projectRoot: "./${srcFolder}/app",
projectRoot: "./${srcFolder}",
projectName: "${projectName}",
outDir: './dist/static',
routes: {
Expand Down
2 changes: 1 addition & 1 deletion schematics/scully/src/scully/index_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ describe('scully schematic', () => {
expect(appTree.files).toContain(SCULLY_PATH);
const scullyConfFile = getFileContent(appTree, SCULLY_PATH);
expect(scullyConfFile).toEqual(`exports.config = {
projectRoot: "./src/app",
projectRoot: "./src/",
outDir: './dist/static',
routes: {
}
Expand Down
39 changes: 1 addition & 38 deletions scully.sampleBlog.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ require('./extraPlugin/tocPlugin');
require('./extraPlugin/voidPlugin');

exports.config = {
/** projectRoot is mandatory! */
projectRoot: './projects/sampleBlog/src/app',
/** outDir is where the static distribution files end up */
outDir: './dist/static',
// hostName: '0.0.0.0',
extraRoutes: ['', '/user/:userId/post/:postId'],
extraRoutes: [''],
routes: {
'/demo/:id': {
type: 'extra',
Expand Down Expand Up @@ -49,22 +47,6 @@ exports.config = {
property: 'id',
},
},
'/nouser/:userId/:friendCode': {
// Type is mandatory
type: 'json',
/**
* Every parameter in the route must exist here
*/
userId: {
url: 'https://jsonplaceholder.typicode.com/users',
property: 'id',
},
friendCode: {
/** users are their own friend in this sample ;) */
url: 'https://jsonplaceholder.typicode.com/users?userId=${userId}',
property: 'id',
},
},
'/todos/:todoId': {
// Type is mandatory
type: 'json',
Expand All @@ -82,25 +64,6 @@ exports.config = {
},
},
},
'/nouser/:userId/:posts/:comments': {
// Type is mandatory
type: 'json',
/**
* Every parameter in the route must exist here
*/
userId: {
url: 'https://jsonplaceholder.typicode.com/users',
property: 'id',
},
posts: {
url: 'https://jsonplaceholder.typicode.com/posts?userId=${userId}',
property: 'id',
},
comments: {
url: 'https://jsonplaceholder.typicode.com/comments?postId=${posts}',
property: 'id',
},
},
'/blog/:slug': {
type: 'contentFolder',
postRenderers: ['toc'],
Expand Down
2 changes: 1 addition & 1 deletion scully/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"express": "^4.17.1",
"front-matter": "^3.0.2",
"fs-extra": "^8.1.0",
"guess-parser": "^0.4.13",
"guess-parser": "^0.4.15",
"jsonc": "2.0.0",
"marked": "^0.7.0",
"puppeteer": "^2.0.0",
Expand Down
1 change: 1 addition & 0 deletions scully/renderPlugins/contentRenderPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export async function contentRenderPlugin(html: string, route: HandledRoute) {
try {
const extension = file.split('.').pop();
const {meta, fileContent} = await readFileAndCheckPrePublishSlug(file, route);
// TODO: create additional "routes" for every slug
route.data = {...route.data, ...meta};
const additionalHTML = await handleFile(extension, fileContent);
return insertContent(scullyBegin, scullyEnd, html, additionalHTML, getScript());
Expand Down
15 changes: 14 additions & 1 deletion scully/routerPlugins/traverseAppRoutesPlugin.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,30 @@
import {parseAngularRoutes} from 'guess-parser';
import {join} from 'path';
import * as yargs from 'yargs';
import {scullyConfig} from '../utils/config';
import {existFolder} from '../utils/fsFolder';
import {green, logError, logWarn, yellow} from '../utils/log';

const {sge} = yargs
.boolean('sge')
.alias('sge', 'showGuessError')
.describe('sb', 'dumps the error from guess to the console').argv;

export const traverseAppRoutes = async (appRootFolder = scullyConfig.projectRoot) => {
const extraRoutes = await addExtraRoutes();
let routes = [];
try {
routes = parseAngularRoutes(appRootFolder).map(r => r.path);
const file = join(appRootFolder, 'tsconfig.app.json');
if (!existFolder(file)) {
logWarn(
`We could not find "${yellow(
file
)}". Using the apps source folder as source. This might lead to unpredictable results`
);
routes = parseAngularRoutes(appRootFolder).map(r => r.path);
} else {
routes = parseAngularRoutes(file).map(r => r.path);
}
} catch (e) {
if (sge) {
console.error(e);
Expand Down
3 changes: 1 addition & 2 deletions scully/systemPlugins/storeRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ export async function storeRoutes(routes: HandledRoute[]) {
let staticFile;
try {
const jsonResult = JSON.stringify(routes.map(r => ({route: r.route || '/', ...r.data})));
// logError('root', scullyConfig.projectRoot);
appFile = join(scullyConfig.projectRoot, `..${routesFileName}`);
appFile = join(scullyConfig.sourceRoot, `${routesFileName}`);
createFolderFor(appFile);
writeFileSync(appFile, jsonResult);
staticFile = join(scullyConfig.outDir, routesFileName);
Expand Down
7 changes: 5 additions & 2 deletions scully/utils/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ const loadIt = async () => {
const compiledConfig = await compileConfig();
let angularConfig = {} as any;
let distFolder = join(angularRoot, './dist');
let projectConfig: any = {};
try {
angularConfig = jsonc.parse(readFileSync(join(angularRoot, 'angular.json')).toString());
// TODO: make scully handle other projects as just the default one.
const defaultProject = compiledConfig.projectName;
distFolder = angularConfig.projects[defaultProject].architect.build.options.outputPath;
projectConfig = angularConfig.projects[defaultProject];
distFolder = projectConfig.architect.build.options.outputPath;
if (distFolder.endsWith('dist') && !distFolder.includes('/')) {
logError(
`Your distribution files are in "${yellow(distFolder)}". Please change that to include a subfolder`
Expand All @@ -40,6 +41,8 @@ const loadIt = async () => {
{
homeFolder: angularRoot,
outDir: join(angularRoot, './dist/static/'),
sourceRoot: projectConfig.sourceRoot,
projectRoot: projectConfig.root,
distFolder,
appPort: /** 1864 */ 'herodevs'.split('').reduce((sum, token) => (sum += token.charCodeAt(0)), 1000),
staticport: /** 1668 */ 'scully'.split('').reduce((sum, token) => (sum += token.charCodeAt(0)), 1000),
Expand Down
6 changes: 4 additions & 2 deletions scully/utils/interfacesandenums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ export enum RouteTypes {
export interface ScullyConfig {
/** the name of the project we are using. Provided by Scully itself */
projectName: string;
/** the folder where the app-source is. Can be any off the projects in a repo */
projectRoot: string;
/** the folder where project is. Can be any off the projects in a repo, read from angular.json */
projectRoot?: string;
/** the folder where the project sources resides, read from angular.json */
sourceRoot?: string;
/** Array with string ID's of the content-renderes that will be run on all routes */
defaultPostRenderers: string[];
/** the root of the project (where angular.json lives) */
Expand Down
9 changes: 0 additions & 9 deletions scully/utils/validateConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,6 @@ export async function validateConfig(config: ScullyConfig) {
/** make sure the config is completely loaded */
// await loadConfig;
const result: Partial<ScullyConfig> = {routes: {}};
if (config.projectRoot) {
if (!checkFolderExists(config.projectRoot)) {
error(`projectRoot folder not found "${yellow(config.projectRoot)}"`);
}
result.projectRoot = config.projectRoot;
} else {
// TODO define a constant for the config file name string
error(`projectRoot missing in "${yellow(configFileName)}"`);
}
if (config.routes) {
await Promise.all(
Object.entries(config.routes).map(async ([route, definition]) => {
Expand Down