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

Port of MarkdownTag to a WebComponent #7

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
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
109 changes: 0 additions & 109 deletions README.md

This file was deleted.

73 changes: 0 additions & 73 deletions markdown-tag-GitHub.js

This file was deleted.

128 changes: 0 additions & 128 deletions to-do.md

This file was deleted.

57 changes: 57 additions & 0 deletions version/1.0.0/.build/.build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/**
* Build Script Configuration File
*
* This file controls scripts to run after the compilation of the source code
*/

// OPTIONS
// All paths are relative to the current version directory (e.g: 1.0.0)
const distDir = "dist" // The build output directory
const srcDir = "src" // The source code directory

/*
*****************************************************
******* DON'T EDIT ANYTHING BEYOND THIS POINT *******
*****************************************************
*/

const cleaner = require("./.clean.build.js")
const srcBuilder = require("./source.build.js")
const assetBuilder = require("./assets.build.js")

/**
* Console Color Formatter using ANSI Codes
*/
const consoleColors = {
byNum: (mess, fgNum, bgNum) => {
mess = mess || '';
fgNum = fgNum === undefined ? 31 : fgNum;
bgNum = bgNum === undefined ? 1 : bgNum; //47
return '\u001b[' + fgNum + 'm' + '\u001b[' + bgNum + 'm' + mess + '\u001b[0m' //'\u001b[39m\u001b[49m';
},
black: (mess, fgNum) => consoleColors.byNum(mess, 30, fgNum),
red: (mess, fgNum) => consoleColors.byNum(mess, 31, fgNum),
green: (mess, fgNum) => consoleColors.byNum(mess, 32, fgNum),
yellow: (mess, fgNum) => consoleColors.byNum(mess, 33, fgNum),
blue: (mess, fgNum) => consoleColors.byNum(mess, 34, fgNum),
magenta: (mess, fgNum) => consoleColors.byNum(mess, 35, fgNum),
cyan: (mess, fgNum) => consoleColors.byNum(mess, 36, fgNum),
white: (mess, fgNum) => consoleColors.byNum(mess, 37, fgNum)
};

global.consoleColors = consoleColors

async function init() {
const options = {
distDir,
srcDir
}

console.log(consoleColors.white(" --------------------- ROOT BUILDER --------------------"))
await cleaner.init(options)
await srcBuilder.init(options)
await assetBuilder.init(options)
console.log(consoleColors.white(" ---------------- ROOT BUILDER FINISHED ---------------"))
}

init()
24 changes: 24 additions & 0 deletions version/1.0.0/.build/.clean.build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
Directory cleaner file.

DO NOT EDIT THIS FILE.
To edit options, see '.build.js'
*/

const { rm } = require("fs/promises")

async function cleaner(options) {
console.log(consoleColors.blue("CLEANING UP BUILD DIRECTORY..."))
await rm(options.distDir, { recursive: true, force: true })
console.log(consoleColors.green("SUCCESSFULLY CLEANED BUILD DIRECTORY"))
}

async function init(options) {
console.log(consoleColors.white(" --------------- CLEANUP ---------------"))

await cleaner(options)

console.log(consoleColors.white(" ----------- CLEANUP FINISHED ----------"))
}

module.exports.init = init
73 changes: 73 additions & 0 deletions version/1.0.0/.build/assets.build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*
Asset builder file.

DO NOT EDIT THIS FILE.
To edit options, see '.build.js'
*/

async function assetBuilder(options) {
const distDir = options.distDir || 'dist'
const srcDir = options.srctDir || 'src'
const ignoreExts = [".js", ".mjs", ".cjs"]
const { resolve, join, sep, dirname, extname } = require('path');
const { readdir, mkdir, copyFile } = require('fs').promises;
const { existsSync } = require('fs');
const assets = 0

async function getFiles(dir) {
const dirents = await readdir(dir, { withFileTypes: true });
const files = await Promise.all(dirents.map((dirent) => {
const res = resolve(dir, dirent.name);
return dirent.isDirectory() ? getFiles(res) : res;
}));
return Array.prototype.concat(...files);
}

//(async () => {
let root = join(__dirname || process.cwd(), "../")
let basePath = resolve(join(root, srcDir))

console.log(consoleColors.blue("READING SOURCE CODE DIRECTORY"))
let originals = await getFiles(basePath)
console.log(consoleColors.green("SUCCESSFULLY READ SOURCE CODE DIRECTORY"))

console.log(consoleColors.blue("READING ASSETS PRESENT ON THE SOURCE CODE DIRECTORY"))
originals.forEach(async orig => {
console.log(consoleColors.blue(["ATTEMPTING TO BUILD ASSET", orig].join(" ")))
let _srcFile = orig.replace(basePath, '')
let srcFile = _srcFile.startsWith(sep) ? _srcFile.replace(sep, '') : _srcFile
let reflectedFile = resolve(join(root, distDir, srcFile))
let reflectedDirName = dirname(reflectedFile)

console.log(consoleColors.magenta("ASSERTING ASSET VALIDITY"))
if (ignoreExts.includes(extname(reflectedFile))) {
//console.warn(consoleColors.red(`Could not build asset ${reflectedFile}: Asset is a source code file.`))
return;
}
console.log(consoleColors.green("Asset is valid."))

if (!existsSync(reflectedDirName)) {
console.warn(consoleColors.yellow(`Asset ${reflectedFile}'s parent directory does not exist, creating ${reflectedDirName}.`))
await mkdir(reflectedDirName, {
recursive: true
})
}

console.log(consoleColors.magenta(["COPYING ASSET", orig, "TO", reflectedFile].join(" ")))
await copyFile(orig, reflectedFile)
assets++
console.log(consoleColors.green(["Successfully copied asset", orig, "to", reflectedFile].join(" ")))
})

return { assets }
//})()
}

async function init(options) {
console.log(consoleColors.white(" --------------- ASSET BUILDER --------------"))
const { assets } = await assetBuilder(options)
console.log(consoleColors.cyan(`Finished building ${assets} assets`))
console.log(consoleColors.white(" ----------- ASSET BUILDER FINISHED ----------"))
}

module.exports.init = init
Loading