Migrate to kleur
This commit is contained in:
@ -2,12 +2,12 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/core": "^7.1.2",
|
"@babel/core": "^7.1.2",
|
||||||
"@babel/preset-env": "^7.1.0",
|
"@babel/preset-env": "^7.1.0",
|
||||||
"chalk": "^2.4.1",
|
|
||||||
"codacy-coverage": "^3.2.0",
|
"codacy-coverage": "^3.2.0",
|
||||||
"eslint": "^5.7.0",
|
"eslint": "^5.7.0",
|
||||||
"fs-extra": "^6.0.0",
|
"fs-extra": "^6.0.0",
|
||||||
"html-minifier": "^3.5.20",
|
"html-minifier": "^3.5.20",
|
||||||
"jest": "^23.6.0",
|
"jest": "^23.6.0",
|
||||||
|
"kleur": "^3.0.3",
|
||||||
"markdown-builder": "^0.8.4",
|
"markdown-builder": "^0.8.4",
|
||||||
"markdown-it": "^8.4.2",
|
"markdown-it": "^8.4.2",
|
||||||
"node-sass": "^4.9.3",
|
"node-sass": "^4.9.3",
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
// Load modules
|
// Load modules
|
||||||
const fs = require('fs-extra');
|
const fs = require('fs-extra');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const chalk = require('chalk');
|
const { green, red } = require('kleur');
|
||||||
const util = require('./util');
|
const util = require('./util');
|
||||||
const markdown = require('markdown-builder');
|
const markdown = require('markdown-builder');
|
||||||
const { headers, misc, lists } = markdown;
|
const { headers, misc, lists } = markdown;
|
||||||
@ -28,7 +28,7 @@ const makeExamples = data => {
|
|||||||
|
|
||||||
if (util.isTravisCI() && /^Travis build: \d+/g.test(process.env['TRAVIS_COMMIT_MESSAGE'])) {
|
if (util.isTravisCI() && /^Travis build: \d+/g.test(process.env['TRAVIS_COMMIT_MESSAGE'])) {
|
||||||
console.log(
|
console.log(
|
||||||
`${chalk.green('NOBUILD')} README build terminated, parent commit is a Travis build!`
|
`${green('NOBUILD')} README build terminated, parent commit is a Travis build!`
|
||||||
);
|
);
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
}
|
}
|
||||||
@ -36,7 +36,7 @@ if (
|
|||||||
util.isTravisCI() &&
|
util.isTravisCI() &&
|
||||||
(process.env['TRAVIS_EVENT_TYPE'] === 'cron' || process.env['TRAVIS_EVENT_TYPE'] === 'api')
|
(process.env['TRAVIS_EVENT_TYPE'] === 'cron' || process.env['TRAVIS_EVENT_TYPE'] === 'api')
|
||||||
) {
|
) {
|
||||||
console.log(`${chalk.green('ARCHIVE')} Cron job or custom build, building archive README!`);
|
console.log(`${green('ARCHIVE')} Cron job or custom build, building archive README!`);
|
||||||
console.time('Builder');
|
console.time('Builder');
|
||||||
let snippets = {};
|
let snippets = {};
|
||||||
// Synchronously read all snippets from snippets_archive folder and sort them as necessary (case-insensitive)
|
// Synchronously read all snippets from snippets_archive folder and sort them as necessary (case-insensitive)
|
||||||
@ -48,7 +48,7 @@ if (
|
|||||||
for (const name of snippetFilenames.filter(s => s !== 'README.md'))
|
for (const name of snippetFilenames.filter(s => s !== 'README.md'))
|
||||||
snippets[name] = fs.readFileSync(path.join(SNIPPETS_ARCHIVE_PATH, name), 'utf8');
|
snippets[name] = fs.readFileSync(path.join(SNIPPETS_ARCHIVE_PATH, name), 'utf8');
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(`${chalk.red('ERROR!')} During snippet loading: ${err}`);
|
console.log(`${red('ERROR!')} During snippet loading: ${err}`);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@ -70,11 +70,11 @@ if (
|
|||||||
// Write to the README file of the archive
|
// Write to the README file of the archive
|
||||||
fs.writeFileSync(path.join(SNIPPETS_ARCHIVE_PATH, 'README.md'), output);
|
fs.writeFileSync(path.join(SNIPPETS_ARCHIVE_PATH, 'README.md'), output);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(`${chalk.red('ERROR!')} During README generation for snippets archive: ${err}`);
|
console.log(`${red('ERROR!')} During README generation for snippets archive: ${err}`);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(`${chalk.green('SUCCESS!')} README file generated for snippets archive!`);
|
console.log(`${green('SUCCESS!')} README file generated for snippets archive!`);
|
||||||
console.timeEnd('Builder');
|
console.timeEnd('Builder');
|
||||||
}
|
}
|
||||||
let snippets = {};
|
let snippets = {};
|
||||||
@ -109,7 +109,7 @@ try {
|
|||||||
startPart = fs.readFileSync(path.join(STATIC_PARTS_PATH, 'README-start.md'), 'utf8');
|
startPart = fs.readFileSync(path.join(STATIC_PARTS_PATH, 'README-start.md'), 'utf8');
|
||||||
endPart = fs.readFileSync(path.join(STATIC_PARTS_PATH, 'README-end.md'), 'utf8');
|
endPart = fs.readFileSync(path.join(STATIC_PARTS_PATH, 'README-end.md'), 'utf8');
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(`${chalk.red('ERROR!')} During static part loading: ${err}`);
|
console.log(`${red('ERROR!')} During static part loading: ${err}`);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -169,9 +169,9 @@ try {
|
|||||||
// Write to the README file
|
// Write to the README file
|
||||||
fs.writeFileSync('README.md', output);
|
fs.writeFileSync('README.md', output);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(`${chalk.red('ERROR!')} During README generation: ${err}`);
|
console.log(`${red('ERROR!')} During README generation: ${err}`);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(`${chalk.green('SUCCESS!')} README file generated!`);
|
console.log(`${green('SUCCESS!')} README file generated!`);
|
||||||
console.timeEnd('Builder');
|
console.timeEnd('Builder');
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
// Load modules
|
// Load modules
|
||||||
const fs = require('fs-extra');
|
const fs = require('fs-extra');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const chalk = require('chalk');
|
const { green } = require('kleur');
|
||||||
const util = require('./util');
|
const util = require('./util');
|
||||||
// Paths
|
// Paths
|
||||||
const SNIPPETS_PATH = './snippets';
|
const SNIPPETS_PATH = './snippets';
|
||||||
@ -17,7 +17,7 @@ if (
|
|||||||
process.env['TRAVIS_EVENT_TYPE'] !== 'cron' &&
|
process.env['TRAVIS_EVENT_TYPE'] !== 'cron' &&
|
||||||
process.env['TRAVIS_EVENT_TYPE'] !== 'api'
|
process.env['TRAVIS_EVENT_TYPE'] !== 'api'
|
||||||
) {
|
) {
|
||||||
console.log(`${chalk.green('NOBUILD')} snippet extraction terminated, not a cron or api build!`);
|
console.log(`${green('NOBUILD')} snippet extraction terminated, not a cron or api build!`);
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
}
|
}
|
||||||
// Read data
|
// Read data
|
||||||
@ -80,7 +80,8 @@ let listingData = {
|
|||||||
meta: {
|
meta: {
|
||||||
hash: v.meta.hash
|
hash: v.meta.hash
|
||||||
}
|
}
|
||||||
})),
|
})),
|
||||||
|
|
||||||
meta: {
|
meta: {
|
||||||
specification: 'http://jsonapi.org/format/'
|
specification: 'http://jsonapi.org/format/'
|
||||||
}
|
}
|
||||||
@ -89,5 +90,5 @@ let listingData = {
|
|||||||
fs.writeFileSync(path.join(OUTPUT_PATH, 'snippets.json'), JSON.stringify(completeData, null, 2));
|
fs.writeFileSync(path.join(OUTPUT_PATH, 'snippets.json'), JSON.stringify(completeData, null, 2));
|
||||||
fs.writeFileSync(path.join(OUTPUT_PATH, 'snippetList.json'), JSON.stringify(listingData, null, 2));
|
fs.writeFileSync(path.join(OUTPUT_PATH, 'snippetList.json'), JSON.stringify(listingData, null, 2));
|
||||||
// Display messages and time
|
// Display messages and time
|
||||||
// Display messages and time
|
console.log(`${green('SUCCESS!')} snippets.json and snippetList.json files generated!`);
|
||||||
console.timeEnd('Extractor');
|
console.timeEnd('Extractor');
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
const fs = require('fs-extra');
|
const fs = require('fs-extra');
|
||||||
const chalk = require('chalk');
|
const { red } = require('kleur');
|
||||||
const util = require('../util');
|
const util = require('../util');
|
||||||
|
|
||||||
const glossaryFiles = util.getFilesInDir('./glossary', false);
|
const glossaryFiles = util.getFilesInDir('./glossary', false);
|
||||||
@ -19,6 +19,6 @@ try {
|
|||||||
) + '\n';
|
) + '\n';
|
||||||
fs.writeFileSync('glossary/keyword_database', output);
|
fs.writeFileSync('glossary/keyword_database', output);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(`${chalk.red('ERROR!')} During glossary keyword_database generation: ${err}`);
|
console.log(`${red('ERROR!')} During glossary keyword_database generation: ${err}`);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
const fs = require('fs-extra');
|
const fs = require('fs-extra');
|
||||||
const chalk = require('chalk');
|
const { red } = require('kleur');
|
||||||
const util = require('../util');
|
const util = require('../util');
|
||||||
|
|
||||||
const glossaryFiles = util.getFilesInDir('./glossary', true, ['keyword_database', 'README.md']);
|
const glossaryFiles = util.getFilesInDir('./glossary', true, ['keyword_database', 'README.md']);
|
||||||
@ -54,6 +54,6 @@ try {
|
|||||||
const README = '# 30-seconds-of-code JavaScript Glossary\n\n' + TOC + '\n\n' + fileContents;
|
const README = '# 30-seconds-of-code JavaScript Glossary\n\n' + TOC + '\n\n' + fileContents;
|
||||||
fs.writeFileSync('glossary/README.md', README);
|
fs.writeFileSync('glossary/README.md', README);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(`${chalk.red('ERROR!')} During glossary README generation: ${err}`);
|
console.log(`${red('ERROR!')} During glossary README generation: ${err}`);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,10 +8,10 @@
|
|||||||
const fs = require('fs-extra');
|
const fs = require('fs-extra');
|
||||||
const cp = require('child_process');
|
const cp = require('child_process');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const chalk = require('chalk');
|
const { green, red } = require('kleur');
|
||||||
const util = require('./util');
|
const util = require('./util');
|
||||||
if (util.isTravisCI() && /^Travis build: \d+/g.test(process.env['TRAVIS_COMMIT_MESSAGE'])) {
|
if (util.isTravisCI() && /^Travis build: \d+/g.test(process.env['TRAVIS_COMMIT_MESSAGE'])) {
|
||||||
console.log(`${chalk.green('NOBUILD')} Linting terminated, parent commit is a Travis build!`);
|
console.log(`${green('NOBUILD')} Linting terminated, parent commit is a Travis build!`);
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
}
|
}
|
||||||
const SNIPPETS_PATH = './snippets';
|
const SNIPPETS_PATH = './snippets';
|
||||||
@ -74,10 +74,10 @@ try {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fs.removeSync(TEMP_PATH);
|
fs.removeSync(TEMP_PATH);
|
||||||
console.log(`${chalk.green('SUCCESS!')} Snippet files linted!`);
|
console.log(`${green('SUCCESS!')} Snippet files linted!`);
|
||||||
console.timeEnd('Linter');
|
console.timeEnd('Linter');
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(`${chalk.red('ERROR!')} During linting: ${err}`);
|
console.log(`${red('ERROR!')} During linting: ${err}`);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
const fs = require('fs-extra');
|
const fs = require('fs-extra');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const chalk = require('chalk');
|
const { green, red } = require('kleur');
|
||||||
const util = require('./util');
|
const util = require('./util');
|
||||||
const { rollup } = require('rollup');
|
const { rollup } = require('rollup');
|
||||||
const babel = require('rollup-plugin-babel');
|
const babel = require('rollup-plugin-babel');
|
||||||
@ -143,7 +143,7 @@ async function build() {
|
|||||||
if (util.isTravisCI() && util.isNotTravisCronOrAPI()) {
|
if (util.isTravisCI() && util.isNotTravisCronOrAPI()) {
|
||||||
fs.unlink(ROLLUP_INPUT_FILE);
|
fs.unlink(ROLLUP_INPUT_FILE);
|
||||||
console.log(
|
console.log(
|
||||||
`${chalk.green(
|
`${green(
|
||||||
'NOBUILD'
|
'NOBUILD'
|
||||||
)} Module build terminated, not a cron job or a custom build!`
|
)} Module build terminated, not a cron job or a custom build!`
|
||||||
);
|
);
|
||||||
@ -156,10 +156,10 @@ async function build() {
|
|||||||
// Clean up the temporary input file Rollup used for building the module
|
// Clean up the temporary input file Rollup used for building the module
|
||||||
fs.unlink(ROLLUP_INPUT_FILE);
|
fs.unlink(ROLLUP_INPUT_FILE);
|
||||||
|
|
||||||
console.log(`${chalk.green('SUCCESS!')} Snippet module built!`);
|
console.log(`${green('SUCCESS!')} Snippet module built!`);
|
||||||
console.timeEnd('Packager');
|
console.timeEnd('Packager');
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(`${chalk.red('ERROR!')} During module creation: ${err}`);
|
console.log(`${red('ERROR!')} During module creation: ${err}`);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,10 +4,10 @@
|
|||||||
*/
|
*/
|
||||||
// Load modules
|
// Load modules
|
||||||
const fs = require('fs-extra'),
|
const fs = require('fs-extra'),
|
||||||
chalk = require('chalk');
|
{ black, blue, green, yellow, red, bgWhite } = require('kleur');
|
||||||
const util = require('./util');
|
const util = require('./util');
|
||||||
if (util.isTravisCI() && /^Travis build: \d+/g.test(process.env['TRAVIS_COMMIT_MESSAGE'])) {
|
if (util.isTravisCI() && /^Travis build: \d+/g.test(process.env['TRAVIS_COMMIT_MESSAGE'])) {
|
||||||
console.log(`${chalk.green('NOBUILD')} Tagging terminated, parent commit is a Travis build!`);
|
console.log(`${green('NOBUILD')} Tagging terminated, parent commit is a Travis build!`);
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
}
|
}
|
||||||
// Set variables for paths
|
// Set variables for paths
|
||||||
@ -41,26 +41,26 @@ try {
|
|||||||
} else {
|
} else {
|
||||||
output += `${snippet[0].slice(0, -3)}:uncategorized\n`;
|
output += `${snippet[0].slice(0, -3)}:uncategorized\n`;
|
||||||
missingTags++;
|
missingTags++;
|
||||||
console.log(`${chalk.yellow('Tagged uncategorized:')} ${snippet[0].slice(0, -3)}`);
|
console.log(`${yellow('Tagged uncategorized:')} ${snippet[0].slice(0, -3)}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Write to tag_database
|
// Write to tag_database
|
||||||
fs.writeFileSync('tag_database', output);
|
fs.writeFileSync('tag_database', output);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// Handle errors (hopefully not!)
|
// Handle errors (hopefully not!)
|
||||||
console.log(`${chalk.red('ERROR!')} During tag_database generation: ${err}`);
|
console.log(`${red('ERROR!')} During tag_database generation: ${err}`);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
// Log statistics for the tag_database file
|
// Log statistics for the tag_database file
|
||||||
console.log(`\n${chalk.bgWhite(chalk.black('=== TAG STATS ==='))}`);
|
console.log(`\n${bgWhite(black('=== TAG STATS ==='))}`);
|
||||||
for (let tagData of Object.entries(tagDbStats)
|
for (let tagData of Object.entries(tagDbStats)
|
||||||
.filter(v => v[0] !== 'undefined')
|
.filter(v => v[0] !== 'undefined')
|
||||||
.sort((a, b) => a[0].localeCompare(b[0])))
|
.sort((a, b) => a[0].localeCompare(b[0])))
|
||||||
console.log(`${chalk.green(tagData[0])}: ${tagData[1]} snippets`);
|
console.log(`${green(tagData[0])}: ${tagData[1]} snippets`);
|
||||||
console.log(
|
console.log(
|
||||||
`${chalk.blue("New untagged snippets (will be tagged as 'uncategorized'):")} ${missingTags}\n`
|
`${blue("New untagged snippets (will be tagged as 'uncategorized'):")} ${missingTags}\n`
|
||||||
);
|
);
|
||||||
// Log a success message
|
// Log a success message
|
||||||
console.log(`${chalk.green('SUCCESS!')} tag_database file updated!`);
|
console.log(`${green('SUCCESS!')} tag_database file updated!`);
|
||||||
// Log the time taken
|
// Log the time taken
|
||||||
console.timeEnd('Tagger');
|
console.timeEnd('Tagger');
|
||||||
|
|||||||
@ -7,7 +7,7 @@
|
|||||||
const fs = require('fs-extra'),
|
const fs = require('fs-extra'),
|
||||||
path = require('path');
|
path = require('path');
|
||||||
const childProcess = require('child_process');
|
const childProcess = require('child_process');
|
||||||
const chalk = require('chalk');
|
const { green, yellow, red } = require('kleur');
|
||||||
const util = require('./util');
|
const util = require('./util');
|
||||||
// Declare paths
|
// Declare paths
|
||||||
const SNIPPETS_PATH = './snippets';
|
const SNIPPETS_PATH = './snippets';
|
||||||
@ -23,7 +23,7 @@ try {
|
|||||||
const undefinedTests = [...snippets, ...archivedSnippets].filter(v => !definedTests.includes(v));
|
const undefinedTests = [...snippets, ...archivedSnippets].filter(v => !definedTests.includes(v));
|
||||||
const orphanedTests = [...definedTests.filter(v => ![...snippets, ...archivedSnippets].includes(v))];
|
const orphanedTests = [...definedTests.filter(v => ![...snippets, ...archivedSnippets].includes(v))];
|
||||||
orphanedTests.forEach(snippet => {
|
orphanedTests.forEach(snippet => {
|
||||||
console.log(`${chalk.yellow('WARNING!')} Orphaned test: ${snippet}`);
|
console.log(`${yellow('WARNING!')} Orphaned test: ${snippet}`);
|
||||||
});
|
});
|
||||||
// Create files for undefined tests
|
// Create files for undefined tests
|
||||||
undefinedTests.forEach(snippet => {
|
undefinedTests.forEach(snippet => {
|
||||||
@ -43,9 +43,9 @@ try {
|
|||||||
else {
|
else {
|
||||||
childProcess.execSync('npm test');
|
childProcess.execSync('npm test');
|
||||||
}
|
}
|
||||||
console.log(`${chalk.green('SUCCESS!')} All tests ran successfully!`);
|
console.log(`${green('SUCCESS!')} All tests ran successfully!`);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(`${chalk.red('ERROR!')} During test runs: ${err}`);
|
console.log(`${red('ERROR!')} During test runs: ${err}`);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
console.timeEnd('Tester');
|
console.timeEnd('Tester');
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
const fs = require('fs-extra'),
|
const fs = require('fs-extra'),
|
||||||
path = require('path'),
|
path = require('path'),
|
||||||
chalk = require('chalk'),
|
{ red } = require('kleur'),
|
||||||
crypto = require('crypto');
|
crypto = require('crypto');
|
||||||
const babel = require('@babel/core');
|
const babel = require('@babel/core');
|
||||||
|
|
||||||
@ -33,7 +33,7 @@ const getFilesInDir = (directoryPath, withPath, exclude = null) => {
|
|||||||
}
|
}
|
||||||
return directoryFilenames;
|
return directoryFilenames;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(`${chalk.red('ERROR!')} During snippet loading: ${err}`);
|
console.log(`${red('ERROR!')} During snippet loading: ${err}`);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -47,7 +47,7 @@ const readSnippets = snippetsPath => {
|
|||||||
for (let snippet of snippetFilenames)
|
for (let snippet of snippetFilenames)
|
||||||
snippets[snippet] = fs.readFileSync(path.join(snippetsPath, snippet), 'utf8');
|
snippets[snippet] = fs.readFileSync(path.join(snippetsPath, snippet), 'utf8');
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(`${chalk.red('ERROR!')} During snippet loading: ${err}`);
|
console.log(`${red('ERROR!')} During snippet loading: ${err}`);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
return snippets;
|
return snippets;
|
||||||
@ -71,7 +71,7 @@ const readTags = () => {
|
|||||||
);
|
);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// Handle errors (hopefully not!)
|
// Handle errors (hopefully not!)
|
||||||
console.log(`${chalk.red('ERROR!')} During tag database loading: ${err}`);
|
console.log(`${red('ERROR!')} During tag database loading: ${err}`);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
return tagDbData;
|
return tagDbData;
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
// Load modules
|
// Load modules
|
||||||
const fs = require('fs-extra');
|
const fs = require('fs-extra');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const chalk = require('chalk');
|
const { green } = require('kleur');
|
||||||
let snippetsData = require('../snippet_data/snippets.json');
|
let snippetsData = require('../snippet_data/snippets.json');
|
||||||
// Paths
|
// Paths
|
||||||
const OUTPUT_PATH = './vscode_snippets';
|
const OUTPUT_PATH = './vscode_snippets';
|
||||||
@ -26,7 +26,7 @@ fs.writeFileSync(
|
|||||||
);
|
);
|
||||||
// Display messages and time
|
// Display messages and time
|
||||||
console.log(
|
console.log(
|
||||||
`${chalk.green(
|
`${green(
|
||||||
'SUCCESS!'
|
'SUCCESS!'
|
||||||
)} vscode_snippets/snippets.json file generated!`
|
)} vscode_snippets/snippets.json file generated!`
|
||||||
);
|
);
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
// Load modules
|
// Load modules
|
||||||
const fs = require('fs-extra'),
|
const fs = require('fs-extra'),
|
||||||
path = require('path'),
|
path = require('path'),
|
||||||
chalk = require('chalk'),
|
{ green, red } = require('kleur'),
|
||||||
md = require('markdown-it')(),
|
md = require('markdown-it')(),
|
||||||
minify = require('html-minifier').minify;
|
minify = require('html-minifier').minify;
|
||||||
const util = require('./util');
|
const util = require('./util');
|
||||||
@ -98,7 +98,7 @@ if (
|
|||||||
process.env['TRAVIS_EVENT_TYPE'] !== 'api'
|
process.env['TRAVIS_EVENT_TYPE'] !== 'api'
|
||||||
) {
|
) {
|
||||||
console.log(
|
console.log(
|
||||||
`${chalk.green('NOBUILD')} website build terminated, parent commit is a Travis build!`
|
`${green('NOBUILD')} website build terminated, parent commit is a Travis build!`
|
||||||
);
|
);
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
}
|
}
|
||||||
@ -113,11 +113,11 @@ sass.render(
|
|||||||
function(err, result) {
|
function(err, result) {
|
||||||
if (!err) {
|
if (!err) {
|
||||||
fs.writeFile(path.join('docs', 'style.css'), result.css, function(err2) {
|
fs.writeFile(path.join('docs', 'style.css'), result.css, function(err2) {
|
||||||
if (!err2) console.log(`${chalk.green('SUCCESS!')} style.css file generated!`);
|
if (!err2) console.log(`${green('SUCCESS!')} style.css file generated!`);
|
||||||
else console.log(`${chalk.red('ERROR!')} During style.css file generation: ${err}`);
|
else console.log(`${red('ERROR!')} During style.css file generation: ${err}`);
|
||||||
});
|
});
|
||||||
} else
|
} else
|
||||||
console.log(`${chalk.red('ERROR!')} During style.css file generation: ${err}`);
|
console.log(`${red('ERROR!')} During style.css file generation: ${err}`);
|
||||||
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -156,7 +156,7 @@ try {
|
|||||||
].map(filename => fs.readFileSync(path.join(staticPartsPath, filename), 'utf8'));
|
].map(filename => fs.readFileSync(path.join(staticPartsPath, filename), 'utf8'));
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// Handle errors (hopefully not!)
|
// Handle errors (hopefully not!)
|
||||||
console.log(`${chalk.red('ERROR!')} During static part loading: ${err}`);
|
console.log(`${red('ERROR!')} During static part loading: ${err}`);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
// Load tag data from the database
|
// Load tag data from the database
|
||||||
@ -242,12 +242,12 @@ try {
|
|||||||
page.content
|
page.content
|
||||||
);
|
);
|
||||||
console.log(
|
console.log(
|
||||||
`${chalk.green('SUCCESS!')} ${page.tag === 'array' ? 'index' : page.tag}.html file generated!`
|
`${green('SUCCESS!')} ${page.tag === 'array' ? 'index' : page.tag}.html file generated!`
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// Handle errors (hopefully not!)
|
// Handle errors (hopefully not!)
|
||||||
console.log(`${chalk.red('ERROR!')} During category page generation: ${err}`);
|
console.log(`${red('ERROR!')} During category page generation: ${err}`);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -359,9 +359,9 @@ try {
|
|||||||
const minifiedArchivedOutput = minifyHTML(archivedOutput);
|
const minifiedArchivedOutput = minifyHTML(archivedOutput);
|
||||||
|
|
||||||
fs.writeFileSync(path.join(docsPath, 'archive.html'), minifiedArchivedOutput);
|
fs.writeFileSync(path.join(docsPath, 'archive.html'), minifiedArchivedOutput);
|
||||||
console.log(`${chalk.green('SUCCESS!')} archive.html file generated!`);
|
console.log(`${green('SUCCESS!')} archive.html file generated!`);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(`${chalk.red('ERROR!')} During archive.html generation: ${err}`);
|
console.log(`${red('ERROR!')} During archive.html generation: ${err}`);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -392,9 +392,9 @@ try {
|
|||||||
// Generate and minify 'glossary.html' file
|
// Generate and minify 'glossary.html' file
|
||||||
const minifiedGlossaryOutput = minifyHTML(glossaryOutput);
|
const minifiedGlossaryOutput = minifyHTML(glossaryOutput);
|
||||||
fs.writeFileSync(path.join(docsPath, 'glossary.html'), minifiedGlossaryOutput);
|
fs.writeFileSync(path.join(docsPath, 'glossary.html'), minifiedGlossaryOutput);
|
||||||
console.log(`${chalk.green('SUCCESS!')} glossary.html file generated!`);
|
console.log(`${green('SUCCESS!')} glossary.html file generated!`);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(`${chalk.red('ERROR!')} During glossary.html generation: ${err}`);
|
console.log(`${red('ERROR!')} During glossary.html generation: ${err}`);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -406,9 +406,9 @@ staticFiles.forEach(f => {
|
|||||||
fs.writeFileSync(path.join(docsPath, f), generateMenuForStaticPage(fileData));
|
fs.writeFileSync(path.join(docsPath, f), generateMenuForStaticPage(fileData));
|
||||||
} else
|
} else
|
||||||
fs.copyFileSync(path.join(staticPartsPath, f), path.join(docsPath, f));
|
fs.copyFileSync(path.join(staticPartsPath, f), path.join(docsPath, f));
|
||||||
console.log(`${chalk.green('SUCCESS!')} ${f} file copied!`);
|
console.log(`${green('SUCCESS!')} ${f} file copied!`);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(`${chalk.red('ERROR!')} During ${f} copying: ${err}`);
|
console.log(`${red('ERROR!')} During ${f} copying: ${err}`);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user