Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for setting PlantUML Server URL #29

Merged
merged 1 commit into from
Jan 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions build.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ const generateCompleteMD = async (tree, options) => {
path.parse(pumlFile.dir).name + `.${options.DIAGRAM_FORMAT}`
));
if (!options.GENERATE_LOCAL_IMAGES)
diagramUrl = plantUmlServerUrl(pumlFile.content);
diagramUrl = plantUmlServerUrl(options.PLANTUML_SERVER_URL, options.DIAGRAM_FORMAT, pumlFile.content);

let diagramImage = `![diagram](${diagramUrl})`;
let diagramLink = `[Go to ${path.parse(pumlFile.dir).name} diagram](${diagramUrl})`;
Expand Down Expand Up @@ -231,7 +231,7 @@ const generateCompletePDF = async (tree, options) => {
path.parse(pumlFile.dir).name + `.${options.DIAGRAM_FORMAT}`
));
if (!options.GENERATE_LOCAL_IMAGES)
diagramUrl = plantUmlServerUrl(pumlFile.content);
diagramUrl = plantUmlServerUrl(options.PLANTUML_SERVER_URL, options.DIAGRAM_FORMAT, pumlFile.content);

let diagramImage = `![diagram](${diagramUrl})`;

Expand Down Expand Up @@ -362,7 +362,7 @@ const generateMD = async (tree, options, onProgress) => {
path.parse(pumlFile.dir).name + `.${options.DIAGRAM_FORMAT}`
));
if (!options.GENERATE_LOCAL_IMAGES)
diagramUrl = plantUmlServerUrl(pumlFile.content);
diagramUrl = plantUmlServerUrl(options.PLANTUML_SERVER_URL, options.DIAGRAM_FORMAT, pumlFile.content);

let diagramImage = `![diagram](${diagramUrl})`;
let diagramLink = `[Go to ${path.parse(pumlFile.dir).name} diagram](${diagramUrl})`;
Expand Down Expand Up @@ -423,7 +423,7 @@ const generatePDF = async (tree, options, onProgress) => {
MD += '\n\n';
let diagramUrl = encodeURIPath(path.parse(pumlFile.dir).name + `.${options.DIAGRAM_FORMAT}`);
if (!options.GENERATE_LOCAL_IMAGES)
diagramUrl = plantUmlServerUrl(pumlFile.content);
diagramUrl = plantUmlServerUrl(options.PLANTUML_SERVER_URL, options.DIAGRAM_FORMAT, pumlFile.content);

let diagramImage = `![diagram](${diagramUrl})`;

Expand Down Expand Up @@ -523,7 +523,7 @@ const generateWebMD = async (tree, options) => {
path.parse(pumlFile.dir).name + `.${options.DIAGRAM_FORMAT}`
));
if (!options.GENERATE_LOCAL_IMAGES)
diagramUrl = plantUmlServerUrl(pumlFile.content);
diagramUrl = plantUmlServerUrl(options.PLANTUML_SERVER_URL, options.DIAGRAM_FORMAT, pumlFile.content);

let diagramImage = `![diagram](${diagramUrl})`;
let diagramLink = `[Go to ${path.parse(pumlFile.dir).name} diagram](${diagramUrl})`;
Expand Down
22 changes: 22 additions & 0 deletions cli.collect.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,28 @@ module.exports = async (currentConfiguration, conf, program) => {
}
}

if (!currentConfiguration.PLANTUML_SERVER_URL || program.config) {
responses = await inquirer.prompt({
type: 'input',
name: 'plantumlServerUrl',
message: 'PlantUML Server URL',
default: currentConfiguration.PLANTUML_SERVER_URL || 'https://www.plantuml.com/plantuml',
validate: validate(joi.string().trim().optional())
});
conf.set('plantumlServerUrl', responses.plantumlServerUrl)
}

if (!currentConfiguration.DIAGRAM_FORMAT || program.config) {
responses = await inquirer.prompt({
type: 'input',
name: 'diagramFormat',
message: 'Diagram Image Format',
default: currentConfiguration.DIAGRAM_FORMAT || 'svg',
validate: validate(joi.string().trim().optional())
});
conf.set('diagramFormat', responses.diagramFormat)
}

if (!currentConfiguration.CHARSET || program.config) {
responses = await inquirer.prompt({
type: 'input',
Expand Down
5 changes: 3 additions & 2 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,10 @@ const getOptions = conf => {
CHARSET: conf.get('charset'),
WEB_PORT: conf.get('webPort'),
HAS_RUN: conf.get('hasRun'),
PLANTUML_SERVER_URL: conf.get('plantumlServerUrl'),
DIAGRAM_FORMAT: conf.get('diagramFormat'),
MD_FILE_NAME: 'README',
WEB_FILE_NAME: 'HOME',
DIAGRAM_FORMAT: 'svg'
WEB_FILE_NAME: 'HOME'
}
};

Expand Down
2 changes: 1 addition & 1 deletion utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ const urlTextFrom = (s) => {
}
};

const plantUmlServerUrl = content => `https://www.plantuml.com/plantuml/svg/0/${urlTextFrom(content)}`;
const plantUmlServerUrl = (baseURL, imageFormat, content) => `${baseURL}/${imageFormat}/0/${urlTextFrom(content)}`;

const clearConsole = () => {
process.stdout.write('\x1b[2J');
Expand Down