From 8f16dd255bd006806e65b2e1fa89174e67af9516 Mon Sep 17 00:00:00 2001 From: Joe Bottigliero <694253+jbottigliero@users.noreply.github.com> Date: Wed, 22 May 2024 10:40:30 -0500 Subject: [PATCH] initial commit --- .gitignore | 1 + README.md | 9 +++++++++ index.js | 18 ++++++++++++++++++ package.json | 18 ++++++++++++++++++ 4 files changed, 46 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100644 index.js create mode 100644 package.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1fcb152 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +out diff --git a/README.md b/README.md new file mode 100644 index 0000000..a220b39 --- /dev/null +++ b/README.md @@ -0,0 +1,9 @@ +# `generator-hello-world` + +This is a basic example of a `generator` in the static Application Design Approach. A `generator` (static site generator) processes a `static.json` file and produces a static web page or dynamic web application. + +By referencing this `generator` in a `static.json` file and providing a `data.message` value, the `generator` will produce a static web page with the provided `data.message`. + +A template repository that references this generator can be found at: https://github.com/from-static/template-hello-world. + +This template repository can be used to create custom distributions of the generator on GitHub Pages by only modifying the `data.message` value in the `static.json` file. diff --git a/index.js b/index.js new file mode 100644 index 0000000..acd9501 --- /dev/null +++ b/index.js @@ -0,0 +1,18 @@ +const fs = require('fs'); + +console.log('@from-static/generator-hello-world: Configuring "out" directory.') +fs.rmSync('./out', { recursive: true }); +fs.mkdirSync('./out'); + +let _STATIC = {}; + +try { + console.log('@from-static/generator-hello-world: Reading "static.json" file.') + _STATIC = require('./static.json'); +} catch (e) { + console.log('@from-static/generator-hello-world: Error reading "static.json" file.'); +} + +fs.writeFileSync('./out/index.html', _STATIC?.data?.message || ''); + +console.log('@from-static/generator-hello-world: Done!') \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..64ed873 --- /dev/null +++ b/package.json @@ -0,0 +1,18 @@ +{ + "name": "@from-static/generator-hello-world", + "version": "1.0.0", + "description": "An example generator for use in the static Application Design Approach", + "scripts": { + "build": "node index.js" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/from-static/generator-hello-world.git" + }, + "author": "Joe Bottigliero", + "license": "MIT", + "bugs": { + "url": "https://github.com/from-static/generator-hello-world/issues" + }, + "homepage": "https://github.com/from-static/generator-hello-world#readme" +}