From: Ruben Beltran del Rio Date: Fri, 23 Feb 2024 21:04:18 +0000 (+0000) Subject: Remove bin and config files X-Git-Tag: 7.0.0~51 X-Git-Url: https://git.r.bdr.sh/rbdr/blog/commitdiff_plain/442ebaf901a8ca686ce769325054e1f393d43b7c Remove bin and config files --- diff --git a/bin/blog.js b/bin/blog.js deleted file mode 100755 index 3f5db43..0000000 --- a/bin/blog.js +++ /dev/null @@ -1,143 +0,0 @@ -#!/usr/bin/env node -import Config from '../config/config.js'; -import Blog from '../lib/blog.js'; -import Minimist from 'minimist'; - -const internals = { - blog: new Blog(Config), - expectedKeys: [ - 'add', - 'generate', - 'update', - 'publish', - 'publish-archive', - 'add-remote', - 'remove-remote', - 'sync-up', - 'sync-down', - 'version'], - - // Application entry point. Reads arguments and calls the - // corresponding method from the blog lib - - async main() { - - try { - const parsedArguments = this._parseArguments(); - - for (const argument in parsedArguments) { - if (parsedArguments.hasOwnProperty(argument)) { - - const value = parsedArguments[argument]; - - if (argument === 'version') { - console.log('6.0.0'); - return; - } - - if (argument === 'add') { - await internals.blog.add(value); - return; - } - - if (argument === 'update') { - await internals.blog.update(value); - return; - } - - if (argument === 'generate') { - await internals.blog.generate(); - return; - } - - if (argument === 'publish') { - await internals.blog.publish(value); - return; - } - - if (argument === 'publish-archive') { - await internals.blog.publishArchive(value); - return; - } - - if (argument === 'add-remote') { - await internals.blog.addRemote(value); - return; - } - - if (argument === 'remove-remote') { - await internals.blog.removeRemote(); - return; - } - - if (argument === 'sync-up') { - await internals.blog.syncUp(); - return; - } - - if (argument === 'sync-down') { - await internals.blog.syncDown(); - return; - } - } - } - - console.log('Not yet implemented'); - } - catch (err) { - console.error(err.message || err); - this._printUsage(); - process.exit(1); - } - }, - - // Parses arguments and returns them if valid. otherwise Throws - - _parseArguments() { - - const parsedArguments = Minimist(process.argv.slice(2)); - - if (!this._areArgumentsValid(parsedArguments)) { - throw new Error(internals.strings.invalidArguments); - } - - return parsedArguments; - }, - - // Checks if the arguments are valid, returns a boolean value. - - _areArgumentsValid(parsedArguments) { - - const argumentKeys = Object.keys(parsedArguments); - - return argumentKeys.some((key) => internals.expectedKeys.indexOf(key) >= 0); - }, - - // Prints the usage to stderr - - _printUsage() { - - console.error('\nUsage:\n'); - console.error('blog --add \t\t(creates new blog post)'); - console.error('blog --update \t\t(updates latest blog post)'); - console.error('blog --generate \t\t\t(generates the blog assets)'); - console.error('blog --publish \t\t(publishes the blog to an S3 bucket)'); - console.error('blog --publish-archive \t(publishes the archive to a remote host)'); - console.error('blog --add-remote \t\t(adds or updates a git remote to sync with)'); - console.error('blog --remove-remote \t\t\t(removes the git remote)'); - console.error('blog --sync-up \t\t\t\t(pushes to the git remote if configured)'); - console.error('blog --sync-down \t\t\t(pulls from the git remote if configured)'); - console.error('blog --version \t\t\t\t(print the version)'); - } -}; - -// Add the strings, added after declaration so they can consume the -// internals object. - -internals.strings = { - invalidArguments: `Invalid Arguments, expecting one of: ${internals.expectedKeys.join(', ')}` -}; - - - -internals.main(); diff --git a/config/config.js b/config/config.js deleted file mode 100644 index cf2a386..0000000 --- a/config/config.js +++ /dev/null @@ -1,97 +0,0 @@ -import { fileURLToPath } from 'url'; -import { join, resolve, dirname } from 'path'; -import Getenv from 'getenv'; - -const __filename = fileURLToPath(import.meta.url); -const __dirname = dirname(__filename); - -const internals = { - // We'll use this to store configuration, such as the remote config, - // templates, and the static directory. - configDirectory: Getenv('BLOG_CONFIG_DIRECTORY', - resolve( - join( - Getenv( - 'XDG_CONFIG_HOME', - join(Getenv('HOME'), '.config') - ), - 'blog' - ) - ) - ), - // We'll use this to store the actual blog contents. - dataDirectory: Getenv('BLOG_DATA_DIRECTORY', - resolve( - join( - Getenv( - 'XDG_DATA_HOME', - join(Getenv('HOME'), '.local/share') - ), - 'blog' - ) - ) - ), - // We'll use this to store the actual blog contents. - outputDirectory: Getenv('BLOG_OUTPUT_DIRECTORY', - resolve( - join( - Getenv( - 'XDG_CACHE_HOME', - join(Getenv('HOME'), '.cache') - ), - 'blog' - ) - ) - ) -}; - -/** - * The main configuration object for Blog. It will be used to - * initialize all of the sub-components. It can extend any property of - * the blog object. - * - * @memberof Blog - * @typedef {object} tConfiguration - * @property {number} maxPosts=3 the max number of posts that can exist - * at one time - * @property {string} configDirectory=$XDG_CONFIG_HOME/blog the location of - * the configuration files. - * @property {string} dataDirectory=$XDG_DATA_HOME/blog the location of - * the blog data. - * @property {string} outputDirectory=$XDG_CACHE_HOME/blog the location of - * the generated blog files. - * @property {string} postsDirectory=$XDG_DATA_HOME/blog/posts the location of - * the directory where the posts will be stored. - * @property {string} archiveDirectory=$XDG_DATA_HOME/blog/archive the location of - * the directory where the archive will be stored. - * @property {string} staticDirectory=$XDG_DATA_HOME/blog/static the location of - * the directory where the generated files will be placed. NOTE: There - * are some pre-built style files in the default directory, if you - * select another one, make sure you include them manually. - * @property {string} templatesDirectory=$XDG_CONFIG_HOME/blog/templates the - * location of the templates we'll use to generate the index.html, feed.xml, - * and index.txt. - * @property {string} remoteConfig=$XDG_CONFIG_HOME/blog/blogremotee the - * location of the templates we'll use to generate the index.html - */ -export default { - // XDG_CONFIG_HOME and XDG_DATA_HOME defaults. - configDirectory: internals.configDirectory, - dataDirectory: internals.dataDirectory, - outputDirectory: internals.outputDirectory, - - // User configuration, changeable with BLOG_ env variables. - maxPosts: Getenv.int('BLOG_MAX_POSTS', 3), - postsDirectory: resolve(join(internals.dataDirectory, 'posts')), - archiveDirectory: resolve(join(internals.dataDirectory, 'archive')), - staticDirectory: resolve(join(internals.dataDirectory, 'static')), - templatesDirectory: resolve(join(internals.dataDirectory, 'templates')), - - remoteConfig: resolve(join(internals.configDirectory, 'blogremote')), - - blogOutputDirectory: resolve(join(internals.outputDirectory, 'blog')), - archiveOutputDirectory: resolve(join(internals.outputDirectory, 'archive')), - - // Internal config: This can't be modified. - defaultTemplatesDirectory: resolve(join(__dirname, '../templates')) -}; diff --git a/config/env.dist b/config/env.dist deleted file mode 100644 index e69de29..0000000 diff --git a/config/jsdoc.json b/config/jsdoc.json deleted file mode 100644 index 9e05753..0000000 --- a/config/jsdoc.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "plugins": ["plugins/markdown"], - "opts": { - "destination": "doc", - "readme": "README.md", - "template": "node_modules/docdash", - "recurse": true - } -}