diff --git a/.gitignore b/.gitignore index 869550124..af69e2524 100644 --- a/.gitignore +++ b/.gitignore @@ -50,3 +50,4 @@ scully/bin projects/sampleBlog/src/assets/scully-routes.json scully/node_modules scully/.vscode/settings.json +gp.js diff --git a/angular.json b/angular.json index 113037329..04277ecd6 100644 --- a/angular.json +++ b/angular.json @@ -13,6 +13,7 @@ "build": { "builder": "@angular-devkit/build-angular:browser", "options": { + "extractCss": true, "outputPath": "dist/sampleBlog", "index": "projects/sampleBlog/src/index.html", "main": "projects/sampleBlog/src/main.ts", diff --git a/gp.ts b/gp.ts new file mode 100644 index 000000000..efc7e17ab --- /dev/null +++ b/gp.ts @@ -0,0 +1,8 @@ +import {parseAngularRoutes} from 'guess-parser'; +import {join} from 'path'; + +const folder = join(__dirname, './src/app'); + +const r = parseAngularRoutes(folder).map(r => r.path); + +console.table(r); diff --git a/package-lock.json b/package-lock.json index 8f16fa4e1..1fbeec3a5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7626,9 +7626,9 @@ "dev": true }, "guess-parser": { - "version": "0.4.13", - "resolved": "https://registry.npmjs.org/guess-parser/-/guess-parser-0.4.13.tgz", - "integrity": "sha512-aVvBrqCd/Kctf6cacAQrKYp8eIC04K7PzFdl9ZNwn7sZPAr6HcyBoOHcIiCxo0SgkiK0h1LgcScPLSBhUf+0Og==", + "version": "0.4.14", + "resolved": "https://registry.npmjs.org/guess-parser/-/guess-parser-0.4.14.tgz", + "integrity": "sha512-v2gtJxUbX2F4LhS0XX0eeneM92y6G7suqNJ+zAEosY7UB1EIgNIlRfYapwCjVhI13k99+Yh/RlNcS7e4kfrung==", "dev": true, "requires": { "@wessberg/ts-evaluator": "0.0.24" diff --git a/package.json b/package.json index e12399044..0aca2b3d3 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "commit:select": "npx git-cz", "build-bazel": "bazel build //...", "test-bazel": "bazel test //...", + "gp": "npx tsc gp && node gp", "compile-scully-watch": "ibazel build //scully:compile" }, "private": true, @@ -65,7 +66,7 @@ "express": "^4.17.1", "front-matter": "^3.0.2", "fs-extra": "^8.1.0", - "guess-parser": "^0.4.13", + "guess-parser": "^0.4.14", "husky": "^4.0.0-beta.5", "jasmine-core": "~3.5.0", "jasmine-spec-reporter": "~4.2.1", diff --git a/projects/sampleBlog/.vscode/settings.json b/projects/sampleBlog/.vscode/settings.json new file mode 100644 index 000000000..65333e1b8 --- /dev/null +++ b/projects/sampleBlog/.vscode/settings.json @@ -0,0 +1,14 @@ +{ + "workbench.colorCustomizations": { + "activityBar.background": "#352cea", + "activityBar.activeBorder": "#3a0806", + "activityBar.foreground": "#e7e7e7", + "activityBar.inactiveForeground": "#e7e7e799", + "activityBarBadge.background": "#3a0806", + "activityBarBadge.foreground": "#e7e7e7", + "statusBar.background": "#1d15ce", + "statusBarItem.hoverBackground": "#352cea", + "statusBar.foreground": "#e7e7e7" + }, + "peacock.color": "#1d15ce" +} diff --git a/scully.config.js b/scully.config.js deleted file mode 100644 index 755aaa6f9..000000000 --- a/scully.config.js +++ /dev/null @@ -1,116 +0,0 @@ -/** load the plugin */ -require('./extraPlugin/extra-plugin.js'); -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/:post'], - projectName: 'sampleBlog', - routes: { - '/demo/:id': { - type: 'extra', - numberOfPages: 5, - }, - '/home/:topLevel': { - type: 'extra', - data: [ - {title: 'All routes in application', data: 'all'}, - {title: 'Unpublished routes in application', data: 'unpublished'}, - {title: 'Toplevel routes in application', data: ''}, - ], - }, - '/user/:userId': { - // Type is mandatory - type: 'json', - /** - * Every parameter in the route must exist here - */ - userId: { - url: 'https://jsonplaceholder.typicode.com/users', - property: 'id', - }, - }, - '/user/:userId/post/:post': { - // Type is mandatory - type: 'json', - /** - * Every parameter in the route must exist here - */ - userId: { - url: 'https://jsonplaceholder.typicode.com/users', - property: 'id', - }, - post: { - url: 'https://jsonplaceholder.typicode.com/posts?userId=${userId}', - 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', - /** - * Every parameter in the route must exist here - */ - todoId: { - url: 'https://jsonplaceholder.typicode.com/todos', - property: 'id', - /** - * Headers can be sent optionally - */ - headers: { - 'API-KEY': '0123456789', - }, - }, - }, - '/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'], - slug: { - folder: './blog', - }, - }, - '/**': { - type: 'void', - }, - }, -}; diff --git a/scully.sampleBlog.config.js b/scully.sampleBlog.config.js index e6d43f958..b7866995e 100644 --- a/scully.sampleBlog.config.js +++ b/scully.sampleBlog.config.js @@ -9,7 +9,7 @@ exports.config = { /** outDir is where the static distribution files end up */ outDir: './dist/static', // hostName: '0.0.0.0', - extraRoutes: [''], + extraRoutes: ['', '/user/:userId/post/:postId'], routes: { '/demo/:id': { type: 'extra', @@ -34,6 +34,21 @@ exports.config = { property: 'id', }, }, + '/user/:userId/post/:postId': { + // Type is mandatory + type: 'json', + /** + * Every parameter in the route must exist here + */ + userId: { + url: 'https://jsonplaceholder.typicode.com/users', + property: 'id', + }, + postId: { + url: 'https://jsonplaceholder.typicode.com/posts?userId=${userId}', + property: 'id', + }, + }, '/nouser/:userId/:friendCode': { // Type is mandatory type: 'json', diff --git a/scully/package.json b/scully/package.json index 76a298cdd..4d2ceeff5 100644 --- a/scully/package.json +++ b/scully/package.json @@ -1,6 +1,6 @@ { "name": "@scullyio/scully", - "version": "0.0.61", + "version": "0.0.62", "description": "Scully CLI", "repository": { "type": "GIT",