generated from me/template-mit
Add project's current state, started early today (20260730).
This commit is contained in:
+112
@@ -0,0 +1,112 @@
|
|||||||
|
# Logs
|
||||||
|
logs
|
||||||
|
*.log
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
lerna-debug.log*
|
||||||
|
|
||||||
|
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||||
|
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||||
|
|
||||||
|
# Runtime data
|
||||||
|
pids
|
||||||
|
*.pid
|
||||||
|
*.seed
|
||||||
|
*.pid.lock
|
||||||
|
|
||||||
|
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||||
|
lib-cov
|
||||||
|
|
||||||
|
# Coverage directory used by tools like istanbul
|
||||||
|
coverage
|
||||||
|
*.lcov
|
||||||
|
|
||||||
|
# nyc test coverage
|
||||||
|
.nyc_output
|
||||||
|
|
||||||
|
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||||
|
.grunt
|
||||||
|
|
||||||
|
# Bower dependency directory (https://bower.io/)
|
||||||
|
bower_components
|
||||||
|
|
||||||
|
# node-waf configuration
|
||||||
|
.lock-wscript
|
||||||
|
|
||||||
|
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||||
|
build/Release
|
||||||
|
|
||||||
|
# Dependency directories
|
||||||
|
node_modules/
|
||||||
|
jspm_packages/
|
||||||
|
|
||||||
|
# TypeScript v1 declaration files
|
||||||
|
typings/
|
||||||
|
|
||||||
|
# TypeScript cache
|
||||||
|
*.tsbuildinfo
|
||||||
|
|
||||||
|
# Optional npm cache directory
|
||||||
|
.npm
|
||||||
|
|
||||||
|
# Optional eslint cache
|
||||||
|
.eslintcache
|
||||||
|
|
||||||
|
# Microbundle cache
|
||||||
|
.rpt2_cache/
|
||||||
|
.rts2_cache_cjs/
|
||||||
|
.rts2_cache_es/
|
||||||
|
.rts2_cache_umd/
|
||||||
|
|
||||||
|
# Optional REPL history
|
||||||
|
.node_repl_history
|
||||||
|
|
||||||
|
# Output of 'npm pack'
|
||||||
|
*.tgz
|
||||||
|
|
||||||
|
# Yarn Integrity file
|
||||||
|
.yarn-integrity
|
||||||
|
|
||||||
|
# dotenv environment variables file
|
||||||
|
.env
|
||||||
|
.env.test
|
||||||
|
|
||||||
|
# parcel-bundler cache (https://parceljs.org/)
|
||||||
|
.cache
|
||||||
|
|
||||||
|
# Next.js build output
|
||||||
|
.next
|
||||||
|
|
||||||
|
# Nuxt.js build / generate output
|
||||||
|
.nuxt
|
||||||
|
dist
|
||||||
|
|
||||||
|
# Gatsby files
|
||||||
|
.cache/
|
||||||
|
# Comment in the public line in if your project uses Gatsby and *not* Next.js
|
||||||
|
# https://nextjs.org/blog/next-9-1#public-directory-support
|
||||||
|
# public
|
||||||
|
|
||||||
|
# vuepress build output
|
||||||
|
.vuepress/dist
|
||||||
|
|
||||||
|
# Serverless directories
|
||||||
|
.serverless/
|
||||||
|
|
||||||
|
# FuseBox cache
|
||||||
|
.fusebox/
|
||||||
|
|
||||||
|
# DynamoDB Local files
|
||||||
|
.dynamodb/
|
||||||
|
|
||||||
|
# TernJS port file
|
||||||
|
.tern-port
|
||||||
|
|
||||||
|
## Above is Github's recommendations for Node.js. Below are my additions. ##
|
||||||
|
package-lock.json
|
||||||
|
files/*
|
||||||
|
|
||||||
|
# Generated ICS Files
|
||||||
|
*.ics
|
||||||
|
|
||||||
Executable
+111
@@ -0,0 +1,111 @@
|
|||||||
|
#!/usr/bin/env nodejs
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
// 20260730 - Hyperling
|
||||||
|
// Generate .ics files with entries to be imported in a shared calendar.
|
||||||
|
|
||||||
|
/*** Parameters ***/
|
||||||
|
|
||||||
|
const args = process.argv;
|
||||||
|
|
||||||
|
const cmdExec = args[0];
|
||||||
|
const cmdPath = args[1];
|
||||||
|
const startDate = args[2];
|
||||||
|
const endDate = args[3];
|
||||||
|
const DEBUG = args[4];
|
||||||
|
|
||||||
|
console.log(`Running ${cmdPath} with ${cmdExec}...`);
|
||||||
|
console.log("Start Date: " + startDate);
|
||||||
|
console.log(" End Date: " + endDate);
|
||||||
|
|
||||||
|
console.log("Converting strings to dates...");
|
||||||
|
const dayStart = new Date(startDate);
|
||||||
|
const dayEnd = new Date(endDate);
|
||||||
|
console.log("...done!");
|
||||||
|
|
||||||
|
/*** Setup ***/
|
||||||
|
|
||||||
|
// Local Vars
|
||||||
|
|
||||||
|
const name = "Hyperling's Moonth Calendar";
|
||||||
|
const domain = "cloud.hyperling.com";
|
||||||
|
|
||||||
|
// iCalendar Library
|
||||||
|
|
||||||
|
// https://www.npmjs.com/package/ical-generator
|
||||||
|
import ical, { ICalCalendarMethod } from 'ical-generator';
|
||||||
|
const cal =
|
||||||
|
ical({
|
||||||
|
domain: "$domain",
|
||||||
|
name: "$name"
|
||||||
|
})
|
||||||
|
;
|
||||||
|
|
||||||
|
// File System Reading
|
||||||
|
|
||||||
|
import fs from "fs";
|
||||||
|
function readFile (file) {
|
||||||
|
try {
|
||||||
|
const text = fs.readFileSync(file, "utf8");
|
||||||
|
console.log(file + " loaded!");
|
||||||
|
return text;
|
||||||
|
} catch (e) {
|
||||||
|
console.error("ERROR: Could not read " + file + ": ", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function writeFile (name, text) {
|
||||||
|
try {
|
||||||
|
fs.writeFileSync(name, text);
|
||||||
|
console.log(name + " written successfully");
|
||||||
|
} catch (e) {
|
||||||
|
console.error("Error writing " + name + ": ", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const templateTitle = readFile("templates/TITLE.txt")
|
||||||
|
const templateDesc = readFile("templates/DESCRIPTION.txt");
|
||||||
|
|
||||||
|
/*** Main ***/
|
||||||
|
|
||||||
|
const dayOne = new Date("2026-04-01");
|
||||||
|
const dayLength = 1000 * 60 * 60 * 24;
|
||||||
|
function getNumDaysBetween (date1, date2) {
|
||||||
|
return Math.abs((date1-date2)/dayLength);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (
|
||||||
|
let dayCurr = dayStart;
|
||||||
|
dayCurr <= dayEnd;
|
||||||
|
dayCurr.setDate(dayCurr.getDate() + 1)
|
||||||
|
) {
|
||||||
|
|
||||||
|
if (DEBUG) console.log("DEBUG: curr-Apr1 = ", getNumDaysBetween(dayCurr, dayOne));
|
||||||
|
|
||||||
|
// Pull data for UID.
|
||||||
|
const year = dayCurr.getFullYear();
|
||||||
|
const moonth = dayCurr.getMonth();
|
||||||
|
const day = dayCurr.getDate();
|
||||||
|
const extra = "00";
|
||||||
|
|
||||||
|
// Reset vars to defaults.
|
||||||
|
const title = templateTitle
|
||||||
|
.replaceAll("{{MOONTH}}", moonth)
|
||||||
|
.replaceAll("{{DAY}}", day)
|
||||||
|
.replaceAll("{{YEAR}}", year)
|
||||||
|
;
|
||||||
|
const description = templateDesc;
|
||||||
|
|
||||||
|
cal.createEvent({
|
||||||
|
uid: `${year}${moonth}${day}${extra}@${domain}`,
|
||||||
|
start: new Date(dayCurr),
|
||||||
|
allDay: true,
|
||||||
|
summary: title,
|
||||||
|
description: description,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/*** Finish ***/
|
||||||
|
|
||||||
|
// Create Events
|
||||||
|
//cal.save('schedule.ics');
|
||||||
|
writeFile("calendar.ics", cal.toString());
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"dependencies": {
|
||||||
|
"ical-generator": "^11.1.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# 20260730 - Hyperling
|
||||||
|
# Generate .ics files for a shared Moonthly calendar hosted on cloud.hyperling.com.
|
||||||
|
|
||||||
|
export DEBUG=true
|
||||||
|
|
||||||
|
echo "`date` - Running $0"
|
||||||
|
|
||||||
|
## Parameters
|
||||||
|
|
||||||
|
# start date
|
||||||
|
# end date
|
||||||
|
# number of moonths
|
||||||
|
# year
|
||||||
|
|
||||||
|
## Install Pre-Reqs ##
|
||||||
|
|
||||||
|
npm="`which npm`"
|
||||||
|
if [[ ! -s "$npm" ]]; then
|
||||||
|
echo "ERROR: npm does not seem to be available. Please ensure it is installed"
|
||||||
|
echo "Aborting."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo -e "\n`date` - Dependencies | Installing..."
|
||||||
|
$npm install
|
||||||
|
echo -e "\n`date` - Dependencies | Done!\n"
|
||||||
|
|
||||||
|
## Main ##
|
||||||
|
|
||||||
|
# TBD: Remove hardcoded test dates.
|
||||||
|
start_date="2026-07-30"
|
||||||
|
end_date="2026-08-10"
|
||||||
|
|
||||||
|
echo -e "\n`date` - Main | Running...\n"
|
||||||
|
./moonth-generator.js "$start_date" "$end_date" "$DEBUG"
|
||||||
|
echo -e "\n`date` - Main | Done!\n"
|
||||||
|
|
||||||
|
## Finish ##
|
||||||
|
|
||||||
|
exit 0
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
This calendar is generated and maintained by Chad Michael 'Hyperling' Greenwood.
|
||||||
|
|
||||||
|
Feel free to contact me with any questions or concerns.
|
||||||
|
https://blog.hyperling.com/contact
|
||||||
|
|
||||||
|
Calendar Homepage:
|
||||||
|
https://blog.hyperling.com/moonth-calendar
|
||||||
|
|
||||||
|
Calendar Subscription:
|
||||||
|
https://cloud.hyperling.com/remote.php/dav/public-calendars/Rt7jboeJx5awHDyq?export
|
||||||
|
|
||||||
|
Moonth iCal Generator Code:
|
||||||
|
https://git.hyperling.com/me/nodejs-moonth-generator
|
||||||
|
|
||||||
|
Donations:
|
||||||
|
https://hyperling.com/donate
|
||||||
|
|
||||||
|
Last Updated {{GEN_DATE}}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
Moonth {{MOONTH}}/13, Day {{DAY}}, {{YEAR}}
|
||||||
Reference in New Issue
Block a user