Skip to content

Commit

Permalink
feat(CLI): minimal mode
Browse files Browse the repository at this point in the history
fix #572
  • Loading branch information
vogloblinsky committed Jun 21, 2018
1 parent 0a8efe9 commit 9c85bcb
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/config/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,15 @@
false
]
},
"minimal": {
"$id": "/properties/minimal",
"type": "boolean",
"title": "Minimal mode with only documentation. No search, no graph, no coverage.",
"default": false,
"examples": [
false
]
},
"customFavicon": {
"$id": "/properties/customFavicon",
"type": "string",
Expand Down
14 changes: 14 additions & 0 deletions src/index-cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ Note: Certain tabs will only be shown if applicable to a given dependency`,
COMPODOC_DEFAULTS.disableRoutesGraph
)
.option('--disableSearch', 'Do not add the search input', false)
.option('--minimal', 'Minimal mode with only documentation. No search, no graph, no coverage.', false)
.option('--customFavicon [path]', 'Use a custom favicon')
.option('--gaID [id]', 'Google Analytics tracking ID')
.option('--gaSite [site]', 'Google Analytics site name', COMPODOC_DEFAULTS.gaSite)
Expand Down Expand Up @@ -428,6 +429,19 @@ Note: Certain tabs will only be shown if applicable to a given dependency`,
this.configuration.mainData.disableSearch = program.disableSearch;
}

if (configFile.minimal) {
this.configuration.mainData.disableSearch = true;
this.configuration.mainData.disableRoutesGraph = true;
this.configuration.mainData.disableGraph = true;
this.configuration.mainData.disableCoverage = true;
}
if (program.minimal) {
this.configuration.mainData.disableSearch = true;
this.configuration.mainData.disableRoutesGraph = true;
this.configuration.mainData.disableGraph = true;
this.configuration.mainData.disableCoverage = true;
}

if (configFile.customFavicon) {
this.configuration.mainData.customFavicon = configFile.customFavicon;
}
Expand Down
55 changes: 55 additions & 0 deletions test/src/cli/cli-disable-options.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,4 +252,59 @@ describe('CLI disable flags', () => {
expect(file).not.to.contain('book-search-input');
});
});

describe('minimal with --minimal', () => {

let fileContents;

before(function (done) {
tmp.create(distFolder);
let ls = shell('node', [
'./bin/index-cli.js',
'-p', './test/src/sample-files/tsconfig.simple.json',
'--minimal',
'-d', distFolder]);

if (ls.stderr.toString() !== '') {
console.error(`shell error: ${ls.stderr.toString()}`);
done('error');
}
done();
});
after(() => tmp.clean(distFolder));

it('should not generate search JS files', () => {
let file = read(`${distFolder}/index.html`);
expect(file).not.to.contain('lunr.min.js');
const index = exists(distFolder + '/js/search/search_index.js');
expect(index).to.be.false;
});

it('should not generate search input', () => {
let file = read(`${distFolder}/js/menu-wc.js`);
expect(file).not.to.contain('book-search-input');
});

it('should not include the graph on the modules page', () => {
fileContents = read(`${distFolder}/modules.html`);
expect(fileContents).to.not.contain('dependencies.svg');
expect(fileContents).to.not.contain('svg-pan-zoom');
});

it('should not include the graph on the individual modules pages', () => {
fileContents = read(`${distFolder}/modules/AppModule.html`);
expect(fileContents).to.not.contain('modules/AppModule/dependencies.svg');
expect(fileContents).to.not.contain('svg-pan-zoom');
});

it('it should not exist routes_index.js file', () => {
const isFileExists = exists(`${distFolder}/js/routes/routes_index.js`);
expect(isFileExists).to.be.false;
});

it('it should not have coverage page', () => {
const isFileExists = exists(`${distFolder}/coverage.html`);
expect(isFileExists).to.be.false;
});
});
});

0 comments on commit 9c85bcb

Please sign in to comment.