Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianvlupu committed Jan 9, 2021
2 parents 740f8e0 + b4bd424 commit 1d234f8
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 8 deletions.
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

0 comments on commit 1d234f8

Please sign in to comment.