Skip to content

Commit

Permalink
Merge pull request #16 from andstor/develop
Browse files Browse the repository at this point in the history
v1.1.0
  • Loading branch information
andstor authored Feb 26, 2020
2 parents 6689596 + e8e4ab4 commit 3c1a4c8
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 17 deletions.
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ and this project adheres to [Semantic Versioning](https://semver.org).

## [Unreleased]

## [1.1.0] - 2020-02-26
### Added
- Checks for existence of files and directories specified in input variables.

### Changed
- Make the `source_dir` input variable optional.
- Don't set default value of the `recurse` input variable.
- Don't set default value of the `output_dir` input variable.

## [1.0.2] - 2020-02-24
### Fixed
- Specifying input files in JSDoc config files.
Expand All @@ -16,6 +25,7 @@ and this project adheres to [Semantic Versioning](https://semver.org).

## 1.0.0 - 2020-02-22

[Unreleased]: https://github.com/andstor/jsdoc-action/compare/v1.0.2...HEAD
[Unreleased]: https://github.com/andstor/jsdoc-action/compare/v1.1.0...HEAD
[1.1.0]: https://github.com/andstor/jsdoc-action/compare/v1.0.2...v1.1.0
[1.0.2]: https://github.com/andstor/jsdoc-action/compare/v1.0.1...v1.0.2
[1.0.1]: https://github.com/andstor/jsdoc-action/compare/v1.0.0...v1.0.1
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ The following example [workflow step](https://help.github.com/en/actions/configu
uses: andstor/jsdoc-action@v1
with:
source_dir: ./src
recurse: true
output_dir: ./out
```
Expand All @@ -28,9 +29,9 @@ The following input variables options can/must be configured:
|Input variable|Necessity|Description|Default|
|----|----|----|----|
|`source_dir`|Required|Source directory to build documentation from.||
|`source_dir`|Optional|Source directory to build documentation from.||
|`output_dir`|Optional|Output folder for the generated documentation.|`./out`|
|`recurse`|Optional|Recurse into subdirectories when scanning for source files.|`true`|
|`recurse`|Optional|Recurse into subdirectories when scanning for source files.|`false`|
|`config_file`|Optional|The path to a JSDoc configuration file.||
|`template_name`|Optional|The name of a JSDoc template package to install. Will run a `npm install template_name`.||
|`template_dir`|Optional|The relative location of the template files directory within the template package.||
Expand Down
4 changes: 1 addition & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@ branding:
inputs:
source_dir:
description: 'Source directory to build documentation from'
required: true
required: false
output_dir:
description: 'Output folder for the generated documentation'
required: false
default: './out'
recurse:
description: 'Recurse into subdirectories when scanning for source files'
required: false
default: true
config_file:
description: 'The path to a JSDoc configuration file'
required: false
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jsdoc-action",
"version": "1.0.2",
"version": "1.1.0",
"description": "GitHub Action to build JSDoc documentation",
"main": "src/index.js",
"scripts": {
Expand Down
33 changes: 24 additions & 9 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,47 @@ async function run() {
try {
const GITHUB_WORKSPACE = process.env.GITHUB_WORKSPACE;

const source_dir = core.getInput('source_dir', { required: true });
const recurse = core.getInput('recurse') || true;
const output_dir = core.getInput('output_dir') || './out';
const source_dir = core.getInput('source_dir');
const recurse = core.getInput('recurse');
const output_dir = core.getInput('output_dir');
const config_file = core.getInput('config_file');
const template_name = core.getInput('template_name');
const template_dir = core.getInput('template_dir') || '';
const front_page = core.getInput('front_page');

if (config_file) {
if (source_dir) {
try {
await fs.promises.access(config_file);
const srcPath = path.join(GITHUB_WORKSPACE, source_dir);
await fs.promises.access(srcPath);
} catch (error) {
core.setFailed('⛔️ Source directory does not exist');
return;
}
}

if (config_file) {
try {
const configPath = path.join(GITHUB_WORKSPACE, config_file);
await fs.promises.access(configPath);
} catch (error) {
core.setFailed('⛔️ Config file does not exist');
return;
}
}

if (template_name) {
await installer.install(template_name);
}

const jsdocPath = path.join(__dirname, '../node_modules/jsdoc/jsdoc.js');
const srcPath = path.join(GITHUB_WORKSPACE, source_dir);

let cmd = 'node';
let args = [jsdocPath, srcPath];
let args = [jsdocPath];

if (source_dir) {
const srcPath = path.join(GITHUB_WORKSPACE, source_dir);
args.push(srcPath);
}
if (recurse) {
args.push('-r');
}
Expand All @@ -50,9 +64,10 @@ async function run() {
let readmePath = path.join(GITHUB_WORKSPACE, front_page);
args.push('-R', readmePath);
}
args.push('-d', path.join(GITHUB_WORKSPACE, output_dir));
if(output_dir) {
args.push('-d', path.join(GITHUB_WORKSPACE, output_dir));
}

//const actionPath = path.join(__dirname, '../');
core.info(`📝 Generating documentation`);
await exec.exec(cmd, args);
core.info(`🎉 Documentation 📖 has ben generated to the ${output_dir} folder 📁`);
Expand Down

0 comments on commit 3c1a4c8

Please sign in to comment.