Skip to content

Commit cfc92c1

Browse files
committed
fix(docs-site): prepush hook for docs changes
Signed-off-by: AgentEnder <craigorycoppola@gmail.com>
1 parent 6e077f3 commit cfc92c1

File tree

10 files changed

+89
-11
lines changed

10 files changed

+89
-11
lines changed

.husky/pre-push

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
yarn documentation:check

.releaserc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ module.exports = {
4242
'npx ts-node tools/scripts/publish-all ${nextRelease.version} ${nextRelease.channel}',
4343
'nx deploy docs-site',
4444
].join(' && '),
45+
successCmd: 'nx deploy docs-site',
4546
},
4647
],
4748
[

apps/domain/existing-app/Proj.Domain.ExistingApp.csproj

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

docs/core/generators/app.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,7 @@ Generate a dotnet project under the application directory.
3333
### skipOutputPathManipulation
3434

3535
- (boolean): Skip XML changes for default build path
36+
37+
### standalone
38+
39+
- (boolean): Should the project use project.json? If false, the project config is inside workspace.json

docs/core/generators/lib.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,7 @@ Generate a dotnet project under the library directory.
2929
### <span className="required">testTemplate</span>
3030

3131
- (string): Which template should be used for creating the tests project?
32+
33+
### standalone
34+
35+
- (boolean): Should the project use project.json? If false, the project config is inside workspace.json

docs/core/generators/test.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# @nx-dotnet/core:test
2+
3+
## NxDotnet Test Generator
4+
5+
Generate a .NET test project for an existing application or library
6+
7+
## Options
8+
9+
### <span className="required">name</span>
10+
11+
- (string): The existing project to generate tests for
12+
13+
### <span className="required">testTemplate</span>
14+
15+
- (string): Which template should be used for creating the tests project?
16+
17+
### language
18+
19+
- (string): Which language should the project use?
20+
21+
### suffix
22+
23+
- (string): What suffix should be used for the tests project name?
24+
25+
### skipOutputPathManipulation
26+
27+
- (boolean): Skip XML changes for default build path
28+
29+
### standalone
30+
31+
- (boolean): Should the project use project.json? If false, the project config is inside workspace.json

docs/core/index.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ nuget-reference generator
8181

8282
Restores NuGet packages and .NET tools used by the workspace
8383

84+
### [test](./generators/test.md)
85+
86+
Generate a .NET test project for an existing application or library
87+
8488
## Executors
8589

8690
### [build](./executors/build.md)

docs/index.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ slug: /
88
## [@nx-dotnet/core](./core)
99

1010
- 5 Executors
11-
- 7 Generators
11+
- 8 Generators
1212

13-
## [@nx-dotnet/typescript](./typescript)
13+
## [@nx-dotnet/nx-ghpages](./nx-ghpages)
14+
15+
- 1 Executor
1416

1517
## [@nx-dotnet/nxdoc](./nxdoc)
1618

1719
- 1 Generator
1820

19-
## [@nx-dotnet/nx-ghpages](./nx-ghpages)
20-
21-
- 1 Executor
21+
## [@nx-dotnet/typescript](./typescript)

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232
"semantic-release": "semantic-release",
3333
"ts-node": "ts-node",
3434
"rimraf": "rimraf",
35-
"preinstall": "node ./tools/scripts/hooks/preinstall.js"
35+
"preinstall": "node ./tools/scripts/hooks/preinstall.js",
36+
"documentation:check": "ts-node ./tools/scripts/hooks/documentation.check.ts"
3637
},
3738
"private": false,
3839
"dependencies": {
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
const { execSync } = require('child_process');
2+
const { join } = require('path');
3+
4+
const cwd = join(__dirname, '../../../');
5+
6+
export function getChangedFiles(base = 'master', directory = '.'): string[] {
7+
const ancestor = execSync(`git merge-base HEAD ${base} `).toString().trim();
8+
let cmd = `git diff --name-only ${ancestor} -- ${directory}`;
9+
console.log(`📁 Finding changed files with "${cmd}"`);
10+
const changed: string[] = execSync(cmd, {
11+
cwd,
12+
stdio: ['pipe', 'pipe', 'ignore'],
13+
})
14+
.toString()
15+
.split('\n')
16+
.slice(0, -1);
17+
cmd = `git ls-files -z -o --exclude-standard -- ${directory}`;
18+
console.log(`📂 Finding new files with "${cmd}"`);
19+
const output = execSync(cmd, { cwd }).toString();
20+
const newFiles: string[] = output.trim().length ? output.split(' ') : [];
21+
return changed.concat(newFiles);
22+
}
23+
24+
console.log(`📖 Checking for documentation changes`);
25+
execSync('nx workspace-generator generate-docs');
26+
const changes = getChangedFiles('master', 'docs');
27+
if (changes.length) {
28+
console.log(`❌ Found changes in docs files`);
29+
changes.forEach((file) => {
30+
console.log(` - ${file}`);
31+
});
32+
console.log('➡ Please commit these changes.');
33+
process.exit(1);
34+
}

0 commit comments

Comments
 (0)