Skip to content

Commit d894410

Browse files
authored
Schematics/markdown folder (#3)
* schematics(markdown): add new schematics for support new markdown module/component * schematics(fix): fix merge error * schematics(chore): change changelog
1 parent 98aaf86 commit d894410

20 files changed

+294
-43
lines changed

changelog.md

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
# Coulson
1+
# scully
22

33
1. plugin system is there.
44
2. you can register a new plugin.
55
3. plugins are responsible for validating their on part of the config
66
4. using zonejs to detect page -ready in pupeteer.
7-
5. possibilty to provide your own plugins using coulson.custom.ts (not working yet!)
8-
6. coulson.custom.ts to provide plugins, and mapping/reducers in config
7+
5. possibilty to provide your own plugins using scully.custom.ts (not working yet!)
8+
6. scully.custom.ts to provide plugins, and mapping/reducers in config
99
7. parallel generation of pages. (will be batched in future, now everything is generated at once)
1010
8. fully automated worflow. end user needs only 1 command.
1111
9. easy generating of content (like blogs) traversing folders.
@@ -16,29 +16,26 @@
1616

1717
# Schematics
1818

19-
------
20-
working in some issues in rc3
21-
------
2219

23-
1. ng add @herodevs/coulson-generate
20+
1. ng add @herodevs/scully-generate
2421
--blog => create a blog folder with 1 example of md(example with step to step)
25-
add blog module with blog component with coulsonComponent
22+
add blog module with blog component with scullyComponent
2623
27-
2. ng add @herodevs/coulson-generate --blog=blog_name
28-
2. ng add @herodevs/coulson-generate:add-blog
24+
2. ng add @herodevs/scully-generate --blog=blog_name
25+
2. ng add @herodevs/scully-generate:add-blog
2926
add new blog post in blog folder
3027

3128

32-
3. ng g @herodevs/coulson-generate:add-component
33-
4. ng g @herodevs/coulson-generate:add-blog blog_name
34-
5. ng g @herodevs/coulson-generate:blog blog_name
35-
6. Add coulson to angular.json for add commands into the CLI
29+
3. ng g @herodevs/scully-generate:add-component
30+
4. ng g @herodevs/scully-generate:add-blog blog_name
31+
5. ng g @herodevs/scully-generate:blog blog_name
32+
6. Add scully to angular.json for add commands into the CLI
3633

3734
NEXT:
3835
- write more commands for
3936
- add @latest @next
4037

41-
# Coulson DX
38+
# scully DX
4239

4340
1. Run with Bazel
4441
2. Run with node and recreate servers
-11.7 KB
Binary file not shown.

schematics/scully/src/add-blog/schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"$schema": "http://json-schema.org/schema",
33
"id": "add-component",
4-
"title": "Coulson add component schematic",
4+
"title": "Scully add component schematic",
55
"type": "object",
66
"properties": {
77
"routingScope": {
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import {
2+
Rule, Tree, SchematicContext, externalSchematic, chain,
3+
} from '@angular-devkit/schematics';
4+
import {RunSchematicTask} from '@angular-devkit/schematics/tasks';
5+
import { Schema as MyServiceSchema } from './schema';
6+
// @ts-ignore
7+
export default function(options: MyServiceSchema): Rule {
8+
return (host: Tree, context: SchematicContext) => {
9+
return chain([
10+
externalSchematic('@schematics/angular', 'module', {
11+
name: options.name,
12+
route: options.name,
13+
routing: true,
14+
module: 'app.module.ts'
15+
}),
16+
// tslint:disable-next-line:no-shadowed-variable
17+
(host: Tree, context: SchematicContext) => {
18+
context.addTask(new RunSchematicTask('create-markdown', options), []);
19+
}]);
20+
};
21+
}
22+
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"$schema": "http://json-schema.org/schema",
3+
"id": "add-markdown",
4+
"title": "Scully add markdown schematic",
5+
"type": "object",
6+
"properties": {
7+
"routingScope": {
8+
"enum": ["Child", "Root"],
9+
"type": "string",
10+
"description": "The scope for the new routing module.",
11+
"default": "Child"
12+
},
13+
"name": {
14+
"type": "string",
15+
"description": "add the name for the folder and module"
16+
}
17+
},
18+
"required": []
19+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export interface Schema {
2+
name: string;
3+
}

schematics/scully/src/add-post/schema.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11

22
{
33
"$schema": "http://json-schema.org/schema",
4-
"id": "coulson-ng-add-blog",
5-
"title": "Coulson ng-add-blog schematic",
4+
"id": "Scully-ng-add-blog",
5+
"title": "Scully ng-add-blog schematic",
66
"type": "object",
77
"properties": { },
88
"required": []

schematics/scully/src/collection.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,18 @@
2929
"factory": "./add-post/index",
3030
"schema": "./add-post/schema.json",
3131
"aliases": ["post"]
32+
},
33+
"add-markdown": {
34+
"description": "Add new markdown folder and module",
35+
"factory": "./add-markdown/index",
36+
"schema": "./add-markdown/schema.json",
37+
"aliases": ["markdown"]
38+
},
39+
"create-markdown": {
40+
"description": "Add create markdown folder and module",
41+
"factory": "./create-markdown/index",
42+
"schema": "./create-markdown/schema.json",
43+
"aliases": ["c-markdown"]
3244
}
3345
}
3446
}

schematics/scully/src/create-blog/index.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,25 @@ publish: false
1919
context.logger.info(`✅️Blog ${fullDay}-${name} file created`);
2020
}
2121

22+
context.logger.info(`start json scully`);
23+
// add into scully config
24+
try {
25+
const content: Buffer | null = host.read(`/scully.json`);
26+
let jsonContent;
27+
if (content) { jsonContent = JSON.parse(content.toString()); }
28+
/* tslint:disable:no-string-literal */
29+
jsonContent.routes['/blog/:slug'] = {
30+
type: 'contentFolder',
31+
slug: {
32+
folder: './blog'
33+
}
34+
};
35+
host.overwrite(`/scully.json`, JSON.stringify(jsonContent, undefined, 2));
36+
context.logger.info('✅️ Update scully.json');
37+
} catch (e) {
38+
context.logger.error('Cant update scully.json');
39+
}
40+
2241
// test schematics
2342
let path = './src/files/blog-module/';
2443
if (!host.getDir('./src').subdirs.find(x => x === 'add-component')) {

schematics/scully/src/create-blog/schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"$schema": "http://json-schema.org/schema",
33
"id": "add-component",
4-
"title": "Coulson add component schematic",
4+
"title": "Scully add component schematic",
55
"type": "object",
66
"properties": {
77
"routingScope": {

0 commit comments

Comments
 (0)