Skip to content

Commit f184c45

Browse files
committed
Add metadata files
1 parent af8c061 commit f184c45

File tree

11 files changed

+50
-46
lines changed

11 files changed

+50
-46
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,5 @@ nvim/plugged
2020
nvim/doc
2121
nvim/swaps
2222
nvim/colors
23+
dist
2324

builders.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"$schema": "@angular-devkit/architect/src/builders-schema.json",
3+
"builders": {
4+
"deploy": {
5+
"implementation": "./deploy/builder",
6+
"schema": "./deploy/schema.json",
7+
"description": "Deploy builder"
8+
}
9+
}
10+
}

collection.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"$schema": "@angular-devkit/schematics/collection-schema.json",
3+
"schematics": {
4+
"ng-add": {
5+
"description": "Add GitHub pages deploy schematic",
6+
"factory": "./ng-add#ngAdd"
7+
}
8+
}
9+
}

deploy/actions.ts

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,10 @@ export default async function deploy(
2020
await run.result;
2121

2222
try {
23-
const success = ghPages.publish(projectRoot, {}, err => {
24-
if (err) {
25-
context.logger.error(err);
26-
return;
27-
}
28-
console.log(arguments);
29-
context.logger.info(
30-
`🚀 Your application is now available at https://${
31-
success.hosting.split('/')[1]
32-
}.firebaseapp.com/`
33-
);
34-
});
23+
await ghPages.publish(projectRoot, {});
24+
context.logger.info(
25+
`🚀 Your application is now available at https://${''}.firebaseapp.com/`
26+
);
3527
} catch (e) {
3628
context.logger.error(e);
3729
}

deploy/builder.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,23 @@ export default createBuilder<any>(
2626
throw new Error('Cannot deploy the application without a target');
2727
}
2828

29-
const project = workspace.getProject(context.target.project);
29+
const targets = workspace.getProjectTargets(context.target.project);
30+
31+
if (
32+
!targets ||
33+
!targets.build ||
34+
!targets.build.options ||
35+
!targets.build.options.outputPath
36+
) {
37+
throw new Error('Cannot find the project output directory');
38+
}
3039

3140
try {
32-
await deploy(ghpages, context, join(workspace.root, project.root));
41+
await deploy(
42+
ghpages,
43+
context,
44+
join(workspace.root, targets.build.options.outputPath)
45+
);
3346
} catch (e) {
3447
console.error('Error when trying to deploy: ');
3548
console.error(e.message);

interfaces.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export interface GHPages {
2-
publish(dir: string, options: any, callback: any);
2+
publish(dir: string, options: any): Promise<any>;
33
}
44

55
export interface Project {

ng-add.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ interface DeployOptions {
3636
project: string;
3737
}
3838

39-
export function ngAdd(tree: Tree, options: NgAddOptions) {
39+
export const ngAdd = ({ project: DeployOptions }) => (
40+
tree: Tree,
41+
options: NgAddOptions
42+
) => {
4043
const { path: workspacePath, workspace } = getWorkspace(tree);
4144

4245
if (!options.project) {
@@ -82,4 +85,4 @@ export function ngAdd(tree: Tree, options: NgAddOptions) {
8285

8386
tree.overwrite(workspacePath, JSON.stringify(workspace, null, 2));
8487
return tree;
85-
}
88+
};

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@
44
"description": "Deployment from the Angular CLI to GitHub pages",
55
"main": "index.js",
66
"scripts": {
7+
"build": "rm -rf dist && tsc && cp builders.json collection.json package.json dist && cp deploy/schema.json dist/deploy",
78
"test": "jest"
89
},
10+
"schematics": "./collection.json",
11+
"builders": "./builders.json",
912
"repository": {
1013
"type": "git",
1114
"url": "git+https://github.com/mgechev/ng-deploy-gh-pages.git"
@@ -31,15 +34,13 @@
3134
"@types/jest": "^24.0.15",
3235
"@types/node": "^12.0.10",
3336
"jest": "^24.8.0",
34-
"rxjs": "^6.5.2",
3537
"ts-jest": "^24.0.2",
3638
"typescript": "^3.5.2"
3739
},
3840
"peerDependencies": {
3941
"@angular-devkit/architect": "^0.800.6",
4042
"@angular-devkit/core": "^8.0.6",
41-
"@angular-devkit/schematics": "^8.0.6",
42-
"rxjs": "^6.5.2"
43+
"@angular-devkit/schematics": "^8.0.6"
4344
},
4445
"dependencies": {
4546
"gh-pages": "^2.0.1"

tsconfig-esm.json

Lines changed: 0 additions & 17 deletions
This file was deleted.

tsconfig-test.json

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)