Skip to content

Commit

Permalink
fix(docs-site): prepush hook for docs changes
Browse files Browse the repository at this point in the history
Signed-off-by: AgentEnder <craigorycoppola@gmail.com>
  • Loading branch information
AgentEnder committed Aug 11, 2021
1 parent 6e077f3 commit cfc92c1
Show file tree
Hide file tree
Showing 10 changed files with 89 additions and 11 deletions.
4 changes: 4 additions & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn documentation:check
1 change: 1 addition & 0 deletions .releaserc.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ module.exports = {
'npx ts-node tools/scripts/publish-all ${nextRelease.version} ${nextRelease.channel}',
'nx deploy docs-site',
].join(' && '),
successCmd: 'nx deploy docs-site',
},
],
[
Expand Down
5 changes: 0 additions & 5 deletions apps/domain/existing-app/Proj.Domain.ExistingApp.csproj

This file was deleted.

4 changes: 4 additions & 0 deletions docs/core/generators/app.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,7 @@ Generate a dotnet project under the application directory.
### skipOutputPathManipulation

- (boolean): Skip XML changes for default build path

### standalone

- (boolean): Should the project use project.json? If false, the project config is inside workspace.json
4 changes: 4 additions & 0 deletions docs/core/generators/lib.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,7 @@ Generate a dotnet project under the library directory.
### <span className="required">testTemplate</span>

- (string): Which template should be used for creating the tests project?

### standalone

- (boolean): Should the project use project.json? If false, the project config is inside workspace.json
31 changes: 31 additions & 0 deletions docs/core/generators/test.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# @nx-dotnet/core:test

## NxDotnet Test Generator

Generate a .NET test project for an existing application or library

## Options

### <span className="required">name</span>

- (string): The existing project to generate tests for

### <span className="required">testTemplate</span>

- (string): Which template should be used for creating the tests project?

### language

- (string): Which language should the project use?

### suffix

- (string): What suffix should be used for the tests project name?

### skipOutputPathManipulation

- (boolean): Skip XML changes for default build path

### standalone

- (boolean): Should the project use project.json? If false, the project config is inside workspace.json
4 changes: 4 additions & 0 deletions docs/core/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ nuget-reference generator

Restores NuGet packages and .NET tools used by the workspace

### [test](./generators/test.md)

Generate a .NET test project for an existing application or library

## Executors

### [build](./executors/build.md)
Expand Down
10 changes: 5 additions & 5 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ slug: /
## [@nx-dotnet/core](./core)

- 5 Executors
- 7 Generators
- 8 Generators

## [@nx-dotnet/typescript](./typescript)
## [@nx-dotnet/nx-ghpages](./nx-ghpages)

- 1 Executor

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

- 1 Generator

## [@nx-dotnet/nx-ghpages](./nx-ghpages)

- 1 Executor
## [@nx-dotnet/typescript](./typescript)
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
"semantic-release": "semantic-release",
"ts-node": "ts-node",
"rimraf": "rimraf",
"preinstall": "node ./tools/scripts/hooks/preinstall.js"
"preinstall": "node ./tools/scripts/hooks/preinstall.js",
"documentation:check": "ts-node ./tools/scripts/hooks/documentation.check.ts"
},
"private": false,
"dependencies": {
Expand Down
34 changes: 34 additions & 0 deletions tools/scripts/hooks/documentation.check.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const { execSync } = require('child_process');
const { join } = require('path');

const cwd = join(__dirname, '../../../');

export function getChangedFiles(base = 'master', directory = '.'): string[] {
const ancestor = execSync(`git merge-base HEAD ${base} `).toString().trim();
let cmd = `git diff --name-only ${ancestor} -- ${directory}`;
console.log(`📁 Finding changed files with "${cmd}"`);
const changed: string[] = execSync(cmd, {
cwd,
stdio: ['pipe', 'pipe', 'ignore'],
})
.toString()
.split('\n')
.slice(0, -1);
cmd = `git ls-files -z -o --exclude-standard -- ${directory}`;
console.log(`📂 Finding new files with "${cmd}"`);
const output = execSync(cmd, { cwd }).toString();
const newFiles: string[] = output.trim().length ? output.split(' ') : [];
return changed.concat(newFiles);
}

console.log(`📖 Checking for documentation changes`);
execSync('nx workspace-generator generate-docs');
const changes = getChangedFiles('master', 'docs');
if (changes.length) {
console.log(`❌ Found changes in docs files`);
changes.forEach((file) => {
console.log(` - ${file}`);
});
console.log('➡ Please commit these changes.');
process.exit(1);
}

0 comments on commit cfc92c1

Please sign in to comment.