@nekosuneprojects/newyear-tz-countdown 1.0.2
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/npm-publish-github-packages.yml +65 -0
- package/.github/workflows/npm-publish.yml +86 -0
- package/CHANGELOG.md +14 -0
- package/LICENSE +21 -0
- package/README.md +2 -0
- package/package.json +22 -0
- package/src/index.js +40 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
name: Node.js Package GitHub Mode
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types:
|
|
6
|
+
- published
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: write
|
|
10
|
+
issues: write
|
|
11
|
+
pull-requests: write
|
|
12
|
+
packages: write
|
|
13
|
+
|
|
14
|
+
jobs:
|
|
15
|
+
build:
|
|
16
|
+
runs-on: ubuntu-latest
|
|
17
|
+
steps:
|
|
18
|
+
- name: Checkout repository
|
|
19
|
+
uses: actions/checkout@v4
|
|
20
|
+
|
|
21
|
+
- name: Setup Node.js
|
|
22
|
+
uses: actions/setup-node@v4
|
|
23
|
+
with:
|
|
24
|
+
node-version: 20
|
|
25
|
+
|
|
26
|
+
- name: Install dependencies
|
|
27
|
+
run: npm ci
|
|
28
|
+
|
|
29
|
+
publish-gpr:
|
|
30
|
+
needs: build
|
|
31
|
+
runs-on: ubuntu-latest
|
|
32
|
+
steps:
|
|
33
|
+
- name: Checkout repository
|
|
34
|
+
uses: actions/checkout@v4
|
|
35
|
+
|
|
36
|
+
- name: Setup Node.js for GitHub Packages
|
|
37
|
+
uses: actions/setup-node@v4
|
|
38
|
+
with:
|
|
39
|
+
node-version: 20
|
|
40
|
+
registry-url: https://npm.pkg.github.com/
|
|
41
|
+
|
|
42
|
+
- name: Install dependencies
|
|
43
|
+
run: npm ci
|
|
44
|
+
|
|
45
|
+
# Read version from package.json
|
|
46
|
+
- name: Read version from package.json
|
|
47
|
+
id: read_version
|
|
48
|
+
run: |
|
|
49
|
+
VERSION=$(node -p "require('./package.json').version")
|
|
50
|
+
echo "VERSION=$VERSION" >> $GITHUB_ENV
|
|
51
|
+
|
|
52
|
+
# Publish package to GitHub Packages
|
|
53
|
+
- name: Publish to GitHub Packages
|
|
54
|
+
run: npm publish
|
|
55
|
+
env:
|
|
56
|
+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
57
|
+
|
|
58
|
+
# Tag and push
|
|
59
|
+
- name: Create
|
|
60
|
+
run: |
|
|
61
|
+
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
|
62
|
+
git config --global user.name "GitHub Actions"
|
|
63
|
+
git push origin v${{ env.VERSION }}
|
|
64
|
+
env:
|
|
65
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
name: Node.js Package NPMJS
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types:
|
|
6
|
+
- published
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: write
|
|
10
|
+
issues: write
|
|
11
|
+
pull-requests: write
|
|
12
|
+
packages: write
|
|
13
|
+
|
|
14
|
+
jobs:
|
|
15
|
+
release:
|
|
16
|
+
runs-on: ubuntu-latest
|
|
17
|
+
steps:
|
|
18
|
+
# Checkout project repository
|
|
19
|
+
- name: Checkout
|
|
20
|
+
uses: actions/checkout@v4
|
|
21
|
+
|
|
22
|
+
# Setup Node.js environment
|
|
23
|
+
- name: Setup Node.js
|
|
24
|
+
uses: actions/setup-node@v4
|
|
25
|
+
with:
|
|
26
|
+
node-version: '20'
|
|
27
|
+
registry-url: 'https://registry.npmjs.org/'
|
|
28
|
+
|
|
29
|
+
# Configure Git
|
|
30
|
+
- name: Configure Git
|
|
31
|
+
run: |
|
|
32
|
+
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
|
33
|
+
git config --global user.name "GitHub Actions"
|
|
34
|
+
|
|
35
|
+
# Read current package version
|
|
36
|
+
- name: Read version from package.json
|
|
37
|
+
id: read_version
|
|
38
|
+
run: |
|
|
39
|
+
VERSION=$(node -p "require('./package.json').version")
|
|
40
|
+
echo "VERSION=$VERSION" >> $GITHUB_ENV
|
|
41
|
+
|
|
42
|
+
# Update changelog unreleased section with current version
|
|
43
|
+
- name: Update changelog
|
|
44
|
+
uses: superfaceai/release-changelog-action@v1
|
|
45
|
+
with:
|
|
46
|
+
path-to-changelog: CHANGELOG.md
|
|
47
|
+
version: ${{ env.VERSION }}
|
|
48
|
+
operation: release
|
|
49
|
+
|
|
50
|
+
# Commit and tag
|
|
51
|
+
- name: Commit
|
|
52
|
+
run: |
|
|
53
|
+
git add package.json CHANGELOG.md
|
|
54
|
+
git commit -m "chore: release ${{ env.VERSION }}"
|
|
55
|
+
|
|
56
|
+
# Publish version to npm
|
|
57
|
+
- name: Publish to npm
|
|
58
|
+
run: npm publish --access public
|
|
59
|
+
env:
|
|
60
|
+
NODE_AUTH_TOKEN: ${{ secrets.npm_token }}
|
|
61
|
+
|
|
62
|
+
# Push changes and tags
|
|
63
|
+
#- name: Push changes
|
|
64
|
+
# env:
|
|
65
|
+
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
66
|
+
# run: |
|
|
67
|
+
# git push origin
|
|
68
|
+
# git push origin --tags
|
|
69
|
+
|
|
70
|
+
# Read version changelog
|
|
71
|
+
- id: get_changelog
|
|
72
|
+
name: Get version changelog
|
|
73
|
+
uses: superfaceai/release-changelog-action@v1
|
|
74
|
+
with:
|
|
75
|
+
path-to-changelog: CHANGELOG.md
|
|
76
|
+
version: ${{ env.VERSION }}
|
|
77
|
+
operation: read
|
|
78
|
+
|
|
79
|
+
# Update GitHub release
|
|
80
|
+
- name: Create or update GitHub Release
|
|
81
|
+
uses: softprops/action-gh-release@v1
|
|
82
|
+
with:
|
|
83
|
+
tag_name: v${{ env.VERSION }}
|
|
84
|
+
body: ${{ steps.get_changelog.outputs.changelog }}
|
|
85
|
+
env:
|
|
86
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## Unreleased
|
|
9
|
+
|
|
10
|
+
## 1.0.2 - 2025-12-31
|
|
11
|
+
|
|
12
|
+
## 1.0.0 - 2025-10-13
|
|
13
|
+
### Added
|
|
14
|
+
- First Release
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 NekoSuneProjects
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nekosuneprojects/newyear-tz-countdown",
|
|
3
|
+
"version": "1.0.2",
|
|
4
|
+
"description": "New Year countdown using IANA timezones like America/New_York",
|
|
5
|
+
"main": "src/index.js",
|
|
6
|
+
"type": "commonjs",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"timezone",
|
|
9
|
+
"newyear",
|
|
10
|
+
"countdown",
|
|
11
|
+
"date",
|
|
12
|
+
"time",
|
|
13
|
+
"iana"
|
|
14
|
+
],
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"luxon": "^3.7.2"
|
|
17
|
+
},
|
|
18
|
+
"engines": {
|
|
19
|
+
"node": ">=16"
|
|
20
|
+
},
|
|
21
|
+
"license": "MIT"
|
|
22
|
+
}
|
package/src/index.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
const { DateTime } = require("luxon");
|
|
2
|
+
|
|
3
|
+
function getNewYearCountdown(timeZone) {
|
|
4
|
+
const now = DateTime.now().setZone(timeZone);
|
|
5
|
+
|
|
6
|
+
const target = DateTime.fromObject(
|
|
7
|
+
{
|
|
8
|
+
year: now.year + 1,
|
|
9
|
+
month: 1,
|
|
10
|
+
day: 1,
|
|
11
|
+
hour: 0,
|
|
12
|
+
minute: 0,
|
|
13
|
+
second: 0
|
|
14
|
+
},
|
|
15
|
+
{ zone: timeZone }
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
const diff = target.toMillis() - now.toMillis();
|
|
19
|
+
|
|
20
|
+
if (diff <= 0) {
|
|
21
|
+
return {
|
|
22
|
+
timezone: timeZone,
|
|
23
|
+
targetYear: target.year,
|
|
24
|
+
message: "Happy New Year 🎉"
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const totalSeconds = Math.floor(diff / 1000);
|
|
29
|
+
|
|
30
|
+
return {
|
|
31
|
+
timezone: timeZone,
|
|
32
|
+
targetYear: target.year,
|
|
33
|
+
days: Math.floor(totalSeconds / 86400),
|
|
34
|
+
hours: Math.floor((totalSeconds % 86400) / 3600),
|
|
35
|
+
minutes: Math.floor((totalSeconds % 3600) / 60),
|
|
36
|
+
seconds: totalSeconds % 60
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
module.exports = { getNewYearCountdown };
|