@kayooliveira/today-js 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/daily.yml +70 -0
- package/LICENSE +13 -0
- package/README.md +96 -0
- package/data.json +3 -0
- package/index.d.ts +14 -0
- package/index.js +7 -0
- package/package.json +18 -0
- package/scripts/update-day.js +85 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
name: Every single day
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
schedule:
|
|
5
|
+
- cron: '0 0 * * *'
|
|
6
|
+
workflow_dispatch:
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
update-publish:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
permissions:
|
|
12
|
+
contents: write
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@v3
|
|
15
|
+
|
|
16
|
+
- name: Setup Node.js
|
|
17
|
+
uses: actions/setup-node@v3
|
|
18
|
+
with:
|
|
19
|
+
node-version: '20'
|
|
20
|
+
registry-url: 'https://registry.npmjs.org'
|
|
21
|
+
|
|
22
|
+
- name: Configure Git
|
|
23
|
+
run: |
|
|
24
|
+
git config --global user.name 'Daily Bot'
|
|
25
|
+
git config --global user.email 'bot@to.day'
|
|
26
|
+
|
|
27
|
+
- name: Run Update Day Script
|
|
28
|
+
run: npm run update-day
|
|
29
|
+
|
|
30
|
+
- name: Check for changes
|
|
31
|
+
id: check_changes
|
|
32
|
+
run: |
|
|
33
|
+
if [[ -n $(git status -s) ]]; then
|
|
34
|
+
echo "changes=true" >> $GITHUB_OUTPUT
|
|
35
|
+
fi
|
|
36
|
+
|
|
37
|
+
- name: Commit and Push
|
|
38
|
+
if: steps.check_changes.outputs.changes == 'true'
|
|
39
|
+
run: |
|
|
40
|
+
git add .
|
|
41
|
+
git commit -m "chore(release): enterprise temporal update $(date +'%Y-%m-%d')"
|
|
42
|
+
git push
|
|
43
|
+
|
|
44
|
+
- name: Get Version
|
|
45
|
+
if: steps.check_changes.outputs.changes == 'true'
|
|
46
|
+
id: get_version
|
|
47
|
+
run: |
|
|
48
|
+
echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
|
|
49
|
+
|
|
50
|
+
- name: Create Tag
|
|
51
|
+
if: steps.check_changes.outputs.changes == 'true'
|
|
52
|
+
run: |
|
|
53
|
+
git tag v${{ steps.get_version.outputs.version }}
|
|
54
|
+
git push origin v${{ steps.get_version.outputs.version }}
|
|
55
|
+
|
|
56
|
+
- name: Create GitHub Release
|
|
57
|
+
if: steps.check_changes.outputs.changes == 'true'
|
|
58
|
+
uses: softprops/action-gh-release@v1
|
|
59
|
+
with:
|
|
60
|
+
tag_name: v${{ steps.get_version.outputs.version }}
|
|
61
|
+
body_path: RELEASE_NOTES.md
|
|
62
|
+
name: Release v${{ steps.get_version.outputs.version }} - The "Today" Update
|
|
63
|
+
env:
|
|
64
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
65
|
+
|
|
66
|
+
- name: Publish to NPM
|
|
67
|
+
if: steps.check_changes.outputs.changes == 'true'
|
|
68
|
+
run: npm publish --access public
|
|
69
|
+
env:
|
|
70
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
package/LICENSE
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Copyright (c) 2024 kayooliveira
|
|
2
|
+
|
|
3
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
4
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
5
|
+
copyright notice and this permission notice appear in all copies.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
8
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
9
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
10
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
11
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
12
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
13
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# Today
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+

|
|
6
|
+

|
|
7
|
+

|
|
8
|
+
|
|
9
|
+
**The industry-standard chronological state management solution for distributed enterprise applications.**
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Overview
|
|
14
|
+
|
|
15
|
+
In the fast-paced world of modern software development, determining "what day is it" is a non-trivial problem often plagued by timezone inconsistencies, clock skew, and non-deterministic runtime evaluations.
|
|
16
|
+
|
|
17
|
+
**Today** solves this by providing a single, immutable source of truth for the current date. It leverages a sophisticated **Cron-Based Continuous Temporal Integration (CB-CTI)** pipeline to ensure that your application's concept of "today" is synchronized globally, regardless of server location or client configuration.
|
|
18
|
+
|
|
19
|
+
## Key Features
|
|
20
|
+
|
|
21
|
+
- **🚀 Zero-Latency Temporal Resolution**: By pre-computing the date during the build phase, `today` eliminates the runtime overhead associated with the instantiation of `Date` objects.
|
|
22
|
+
- **🛡️ Deterministic State**: The date is hard-coded into the package distribution. This guarantees that every instance of your application running a specific version of `today` agrees on exactly what day it is.
|
|
23
|
+
- **🔒 Immutable Audit Trail**: Every date change is cryptographically signed and stored in the version control history, providing full audibility for compliance-heavy industries (FinTech, HealthTech).
|
|
24
|
+
- **📦 SemVer-Compatible Chronology**: We utilize a proprietary versioning strategy (`YYYY.M.D`) that aligns software lifecycle management directly with the Gregorian calendar.
|
|
25
|
+
- **☁️ Cloud Agnostic**: Runs everywhere. AWS Lambda, Azure Functions, Google Cloud Run, or your on-premise Kubernetes cluster. `today` is ubiquitous.
|
|
26
|
+
|
|
27
|
+
## Installation
|
|
28
|
+
|
|
29
|
+
Integrate `today` into your enterprise ecosystem via NPM:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
npm install @kayooliveira/today-js
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
*Note: Due to high demand/namespace collision, ensure you are installing the correct package or alias it in your private registry.*
|
|
36
|
+
|
|
37
|
+
## Usage
|
|
38
|
+
|
|
39
|
+
### Basic Implementation
|
|
40
|
+
|
|
41
|
+
```javascript
|
|
42
|
+
import today from '@kayooliveira/today-js';
|
|
43
|
+
|
|
44
|
+
// Synchronous, non-blocking retrieval of the temporal state
|
|
45
|
+
const currentDate = today();
|
|
46
|
+
|
|
47
|
+
console.log(`System Status: Operational. Current Temporal Coordinate: ${currentDate}`);
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Enterprise Pattern (Dependency Injection)
|
|
51
|
+
|
|
52
|
+
```javascript
|
|
53
|
+
class TimeService {
|
|
54
|
+
constructor(dateProvider) {
|
|
55
|
+
this.dateProvider = dateProvider;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
getAuditLogTimestamp() {
|
|
59
|
+
// Guaranteed consistency across microservices
|
|
60
|
+
return this.dateProvider();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const service = new TimeService(require('today'));
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Architecture
|
|
68
|
+
|
|
69
|
+
The `today` ecosystem is built on a robust **Event-Driven Architecture**:
|
|
70
|
+
|
|
71
|
+
1. **Temporal Trigger**: A UTC-aligned chronometer fires a signal at `00:00:00Z`.
|
|
72
|
+
2. **State Rehydration**: The **Automated Maintainer Bot** wakes up, calculates the new temporal vector, and injects it into the `data.json` persistence layer.
|
|
73
|
+
3. **Atomic Release**: A new patch version is synthesized, tagged, and published to the global registry immediately.
|
|
74
|
+
|
|
75
|
+
```mermaid
|
|
76
|
+
graph LR
|
|
77
|
+
A[Time Itself] -->|Trigger| B(GitHub Actions)
|
|
78
|
+
B -->|Compute| C{Is it tomorrow?}
|
|
79
|
+
C -->|Yes| D[Update State]
|
|
80
|
+
D -->|Commit| E[Git Repository]
|
|
81
|
+
E -->|Publish| F[NPM Registry]
|
|
82
|
+
F -->|Depend| G[Your Production App]
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Security & Compliance
|
|
86
|
+
|
|
87
|
+
- **No Runtime Dependencies**: Reduces attack surface area to near zero.
|
|
88
|
+
- **Static Analysis Friendly**: Since the date is a string literal, it can be easily parsed by security auditing tools.
|
|
89
|
+
|
|
90
|
+
## Contributing
|
|
91
|
+
|
|
92
|
+
We welcome contributions from the community. Please ensure all Pull Requests are aligned with linear time progression. Backwards time travel PRs will be rejected.
|
|
93
|
+
|
|
94
|
+
## License
|
|
95
|
+
|
|
96
|
+
ISC © 2025 - Present.
|
package/data.json
ADDED
package/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the current date as a string in YYYY-MM-DD format.
|
|
3
|
+
* The date is statically determined at the time of the package's daily release.
|
|
4
|
+
*
|
|
5
|
+
* @returns The current date string (e.g., "2026-01-08")
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* import today = require('@kayooliveira/today-js');
|
|
9
|
+
* const date = today();
|
|
10
|
+
* console.log(date); // "2026-01-08"
|
|
11
|
+
*/
|
|
12
|
+
declare function today(): string;
|
|
13
|
+
|
|
14
|
+
export = today;
|
package/index.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@kayooliveira/today-js",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A package updated every single day to tell you what day it is.",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"types": "index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
9
|
+
"update-day": "node scripts/update-day.js"
|
|
10
|
+
},
|
|
11
|
+
"keywords": [
|
|
12
|
+
"meme",
|
|
13
|
+
"today",
|
|
14
|
+
"daily"
|
|
15
|
+
],
|
|
16
|
+
"author": "kayooliveira",
|
|
17
|
+
"license": "ISC"
|
|
18
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
|
|
4
|
+
function generateChangelog(dateString) {
|
|
5
|
+
const buzzwords = [
|
|
6
|
+
"Optimized synchronization of temporal state vectors.",
|
|
7
|
+
"Re-calibrated daily cron-job with UTC-0 alignments.",
|
|
8
|
+
"Enhanced deterministic date resolution algorithms.",
|
|
9
|
+
"Audited temporal consistency compliance.",
|
|
10
|
+
"Bumped temporal dependencies to latest epoch.",
|
|
11
|
+
"Mitigated Y2K38 potential overflow risks.",
|
|
12
|
+
"Refactored internal calendar pointer arithmetic.",
|
|
13
|
+
"Adjusted leap-second buffer strategy.",
|
|
14
|
+
"Implemented zero-latency date lookup caching.",
|
|
15
|
+
"Standardized ISO-8601 formatting outputs.",
|
|
16
|
+
"Reduced carbon footprint of date calculation by 0.0001%.",
|
|
17
|
+
"Aligned celestial drift variables."
|
|
18
|
+
];
|
|
19
|
+
|
|
20
|
+
const getRandom = () => buzzwords[Math.floor(Math.random() * buzzwords.length)];
|
|
21
|
+
const changes = new Set();
|
|
22
|
+
while (changes.size < 3) {
|
|
23
|
+
changes.add(getRandom());
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return `## [${dateString}] Enterprise Release Notes
|
|
27
|
+
|
|
28
|
+
### 🚀 Performance Improvements
|
|
29
|
+
- ${Array.from(changes)[0]}
|
|
30
|
+
- ${Array.from(changes)[1]}
|
|
31
|
+
|
|
32
|
+
### 🛡️ Security
|
|
33
|
+
- ${Array.from(changes)[2]}
|
|
34
|
+
|
|
35
|
+
### 📦 Metadata
|
|
36
|
+
- **Compliance Verified**: ✅
|
|
37
|
+
- **Temporal Drift**: 0ms
|
|
38
|
+
`;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// 1. Get current date
|
|
42
|
+
const now = new Date();
|
|
43
|
+
const year = now.getFullYear();
|
|
44
|
+
const month = String(now.getMonth() + 1).padStart(2, '0');
|
|
45
|
+
const day = String(now.getDate()).padStart(2, '0');
|
|
46
|
+
const dateString = `${year}-${month}-${day}`;
|
|
47
|
+
|
|
48
|
+
console.log(`[UPDATE] Updating package for date: ${dateString}`);
|
|
49
|
+
|
|
50
|
+
// 2. Update data.json with the new date
|
|
51
|
+
const dataPath = path.join(__dirname, '..', 'data.json');
|
|
52
|
+
const dataContent = {
|
|
53
|
+
date: dateString
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
fs.writeFileSync(dataPath, JSON.stringify(dataContent, null, 2));
|
|
57
|
+
console.log('[UPDATE] data.json updated.');
|
|
58
|
+
|
|
59
|
+
// 3. Update package.json version
|
|
60
|
+
const packagePath = path.join(__dirname, '..', 'package.json');
|
|
61
|
+
const pkg = require(packagePath);
|
|
62
|
+
|
|
63
|
+
const cleanMonth = parseInt(month);
|
|
64
|
+
const cleanDay = parseInt(day);
|
|
65
|
+
const newVersion = `${year}.${cleanMonth}.${cleanDay}`;
|
|
66
|
+
pkg.version = newVersion;
|
|
67
|
+
|
|
68
|
+
fs.writeFileSync(packagePath, JSON.stringify(pkg, null, 2));
|
|
69
|
+
console.log(`[UPDATE] package.json updated to version ${pkg.version}`);
|
|
70
|
+
|
|
71
|
+
// 4. Generate Changelog/Release Notes
|
|
72
|
+
const notes = generateChangelog(dateString);
|
|
73
|
+
const notesPath = path.join(__dirname, '..', 'RELEASE_NOTES.md');
|
|
74
|
+
fs.writeFileSync(notesPath, notes);
|
|
75
|
+
|
|
76
|
+
// Append to main CHANGELOG.md
|
|
77
|
+
const mainChangelogPath = path.join(__dirname, '..', 'CHANGELOG.md');
|
|
78
|
+
let currentChangelog = "";
|
|
79
|
+
if (fs.existsSync(mainChangelogPath)) {
|
|
80
|
+
currentChangelog = fs.readFileSync(mainChangelogPath, 'utf8');
|
|
81
|
+
}
|
|
82
|
+
const newChangelog = notes + "\n\n" + currentChangelog;
|
|
83
|
+
fs.writeFileSync(mainChangelogPath, newChangelog);
|
|
84
|
+
|
|
85
|
+
console.log('[UPDATE] Changelogs generated.');
|