Compare commits
3 commits
b8d8ec0fe2
...
5086b59c89
Author | SHA1 | Date | |
---|---|---|---|
5086b59c89 | |||
50e4790fbf | |||
d85c812fbb |
13 changed files with 58 additions and 95 deletions
|
@ -31,6 +31,8 @@ jobs:
|
||||||
node-version: 20.x
|
node-version: 20.x
|
||||||
- run: yarn install --frozen-lockfile
|
- run: yarn install --frozen-lockfile
|
||||||
- run: yarn build
|
- run: yarn build
|
||||||
|
- run: yarn package
|
||||||
|
- run: cp -r ./bin ${{ secrets.PROD_REPO_PATH }}
|
||||||
- uses: https://github.com/JS-DevTools/npm-publish@v3
|
- uses: https://github.com/JS-DevTools/npm-publish@v3
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.NPM_TOKEN }}
|
token: ${{ secrets.NPM_TOKEN }}
|
35
.forgejo/workflows/staging.yml
Normal file
35
.forgejo/workflows/staging.yml
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
name: Stage
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- develop
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
|
||||||
|
runs-on: node
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Use Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: 20.x
|
||||||
|
- run: yarn install --frozen-lockfile
|
||||||
|
- run: yarn build
|
||||||
|
- run: yarn test
|
||||||
|
- run: yarn lint
|
||||||
|
|
||||||
|
rsync:
|
||||||
|
needs: build
|
||||||
|
runs-on: node
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: 20.x
|
||||||
|
- run: yarn install --frozen-lockfile
|
||||||
|
- run: yarn build
|
||||||
|
- run: yarn package
|
||||||
|
- run: cp -r ./bin ${{ secrets.STAGE_REPO_PATH }}
|
|
@ -7,7 +7,6 @@ on:
|
||||||
- hotfix/*
|
- hotfix/*
|
||||||
- renovate/*
|
- renovate/*
|
||||||
- dependabot/*
|
- dependabot/*
|
||||||
- develop
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
|
|
|
@ -1,92 +0,0 @@
|
||||||
steps:
|
|
||||||
build:
|
|
||||||
# Build and test
|
|
||||||
image: node
|
|
||||||
commands:
|
|
||||||
- yarn install --frozen-lockfile
|
|
||||||
- yarn build
|
|
||||||
when:
|
|
||||||
event: [ push, pull_request ]
|
|
||||||
branch: [ hotfix/*, feature/*, renovate/*, develop, main ]
|
|
||||||
lint:
|
|
||||||
image: node
|
|
||||||
commands:
|
|
||||||
- yarn lint
|
|
||||||
when:
|
|
||||||
event: [ push, pull_request ]
|
|
||||||
branch: [ hotfix/*, feature/*, renovate/*, develop, main ]
|
|
||||||
test:
|
|
||||||
image: node
|
|
||||||
commands:
|
|
||||||
- yarn test
|
|
||||||
when:
|
|
||||||
event: [ push, pull_request ]
|
|
||||||
branch: [ hotfix/*, feature/*, renovate/*, develop, main ]
|
|
||||||
|
|
||||||
# Package production build
|
|
||||||
package_prod:
|
|
||||||
image: node
|
|
||||||
commands:
|
|
||||||
- apt install unzip -y
|
|
||||||
- wget https://github.com/xerub/ldid/releases/download/42/ldid.zip
|
|
||||||
- unzip ldid.zip
|
|
||||||
- mkdir /opt/ldid/
|
|
||||||
- cp linux64/ldid /opt/ldid/
|
|
||||||
- export PATH=/opt/ldid:$PATH
|
|
||||||
- yarn package
|
|
||||||
when:
|
|
||||||
event: tag
|
|
||||||
branch: main
|
|
||||||
rsync_prod:
|
|
||||||
image: alpine
|
|
||||||
secrets: [ ssh_key ]
|
|
||||||
commands:
|
|
||||||
- apk add rsync openssh-client
|
|
||||||
- eval `ssh-agent -s`
|
|
||||||
- echo "$SSH_KEY" | tr -d '\r' | ssh-add -
|
|
||||||
- rsync -e "ssh -o StrictHostKeyChecking=no" -r ./bin vylpes@192.168.1.115:/home/vylpes/apps/random-bunny/random-bunny_prod
|
|
||||||
when:
|
|
||||||
event: tag
|
|
||||||
branch: main
|
|
||||||
|
|
||||||
# Package stage build
|
|
||||||
package_stage:
|
|
||||||
image: node
|
|
||||||
commands:
|
|
||||||
- apt install unzip -y
|
|
||||||
- wget https://github.com/xerub/ldid/releases/download/42/ldid.zip
|
|
||||||
- unzip ldid.zip
|
|
||||||
- mkdir /opt/ldid/
|
|
||||||
- cp linux64/ldid /opt/ldid/
|
|
||||||
- export PATH=/opt/ldid:$PATH
|
|
||||||
- yarn package
|
|
||||||
when:
|
|
||||||
event: push
|
|
||||||
branch: develop
|
|
||||||
rsync_stage:
|
|
||||||
image: alpine
|
|
||||||
secrets: [ ssh_key ]
|
|
||||||
commands:
|
|
||||||
- apk add rsync openssh-client
|
|
||||||
- eval `ssh-agent -s`
|
|
||||||
- echo "$SSH_KEY" | tr -d '\r' | ssh-add -
|
|
||||||
- rsync -e "ssh -o StrictHostKeyChecking=no" -r ./bin vylpes@192.168.1.115:/home/vylpes/apps/random-bunny/random-bunny_stage
|
|
||||||
when:
|
|
||||||
event: push
|
|
||||||
branch: develop
|
|
||||||
|
|
||||||
# Publish to NPM
|
|
||||||
publish:
|
|
||||||
image: plugins/npm
|
|
||||||
settings:
|
|
||||||
username:
|
|
||||||
from_secret: NPM_USERNAME
|
|
||||||
email:
|
|
||||||
from_secret: NPM_EMAIL
|
|
||||||
password:
|
|
||||||
from_secret: NPM_PASSWORD
|
|
||||||
api_key:
|
|
||||||
from_secret: NPM_TOKEN
|
|
||||||
when:
|
|
||||||
event: tag
|
|
||||||
branch: main
|
|
|
@ -25,6 +25,7 @@ By default, the command will fetch a random image from `r/rabbits` and return it
|
||||||
$ random-bunny
|
$ random-bunny
|
||||||
|
|
||||||
Archived = false
|
Archived = false
|
||||||
|
Author = Rabbit_Owner
|
||||||
Downvotes = 0
|
Downvotes = 0
|
||||||
Hidden = false
|
Hidden = false
|
||||||
Permalink = /r/Rabbits/comments/1av1rg9/cute_baby_bun/
|
Permalink = /r/Rabbits/comments/1av1rg9/cute_baby_bun/
|
||||||
|
@ -72,7 +73,7 @@ $ random-bunny --json
|
||||||
|
|
||||||
$ randon-bunny -j
|
$ randon-bunny -j
|
||||||
|
|
||||||
{"Archived":false,"Downs":0,"Hidden":false,"Permalink":"/r/Rabbits/comments/1av1rg9/cute_baby_bun/","Subreddit":"Rabbits","SubredditSubscribers":486085,"Title":"Cute baby bun","Ups":210,"Url":"https://i.redd.it/sfz0srdrimjc1.png"}
|
{"Archived":false,"Author":"Rabbit_Owner","Downs":0,"Hidden":false,"Permalink":"/r/Rabbits/comments/1av1rg9/cute_baby_bun/","Subreddit":"Rabbits","SubredditSubscribers":486085,"Title":"Cute baby bun","Ups":210,"Url":"https://i.redd.it/sfz0srdrimjc1.png"}
|
||||||
```
|
```
|
||||||
|
|
||||||
## Sort
|
## Sort
|
||||||
|
|
|
@ -37,6 +37,7 @@ Returns a `json string` for a random post. Accepts 3 arguments: `subreddit`, `so
|
||||||
|
|
||||||
The json string which gets returned consists of:
|
The json string which gets returned consists of:
|
||||||
- archived
|
- archived
|
||||||
|
- author
|
||||||
- downs
|
- downs
|
||||||
- hidden
|
- hidden
|
||||||
- permalink
|
- permalink
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
export default interface IFetchResult {
|
export default interface IFetchResult {
|
||||||
data: {
|
data: {
|
||||||
archived: boolean,
|
archived: boolean,
|
||||||
|
author: string,
|
||||||
downs: number,
|
downs: number,
|
||||||
hidden: boolean,
|
hidden: boolean,
|
||||||
permalink: string,
|
permalink: string,
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
export default interface IRedditResult {
|
export default interface IRedditResult {
|
||||||
Archived: boolean,
|
Archived: boolean,
|
||||||
|
Author: string,
|
||||||
Downs: number,
|
Downs: number,
|
||||||
Hidden: boolean,
|
Hidden: boolean,
|
||||||
Permalink: string,
|
Permalink: string,
|
||||||
|
|
|
@ -12,6 +12,7 @@ export default class OutputHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
outputLines.push(`Archived = ${result.Archived}`);
|
outputLines.push(`Archived = ${result.Archived}`);
|
||||||
|
outputLines.push(`Author = ${result.Author}`);
|
||||||
outputLines.push(`Downvotes = ${result.Downs}`);
|
outputLines.push(`Downvotes = ${result.Downs}`);
|
||||||
outputLines.push(`Hidden = ${result.Hidden}`);
|
outputLines.push(`Hidden = ${result.Hidden}`);
|
||||||
outputLines.push(`Permalink = ${result.Permalink}`);
|
outputLines.push(`Permalink = ${result.Permalink}`);
|
||||||
|
|
|
@ -118,6 +118,7 @@ export default async function randomBunny(subreddit: string, sortBy: "new" | "ho
|
||||||
}
|
}
|
||||||
|
|
||||||
const redditResult: IRedditResult = {
|
const redditResult: IRedditResult = {
|
||||||
|
Author: randomData['author'],
|
||||||
Archived: randomData['archived'],
|
Archived: randomData['archived'],
|
||||||
Downs: randomData['downs'],
|
Downs: randomData['downs'],
|
||||||
Hidden: randomData['hidden'],
|
Hidden: randomData['hidden'],
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
exports[`GenerateOutput EXPECT standout output to be returned 1`] = `
|
exports[`GenerateOutput EXPECT standout output to be returned 1`] = `
|
||||||
"Archived = false
|
"Archived = false
|
||||||
|
Author = author
|
||||||
Downvotes = 0
|
Downvotes = 0
|
||||||
Hidden = false
|
Hidden = false
|
||||||
Permalink = /r/Rabbits/comments/1dj8pbt/this_is_my_ms_bear/
|
Permalink = /r/Rabbits/comments/1dj8pbt/this_is_my_ms_bear/
|
||||||
|
@ -12,10 +13,11 @@ Upvotes = 17
|
||||||
Url = https://preview.redd.it/d5yno653zf7d1.jpg?width=640&crop=smart&auto=webp&s=5064d1caec3c12ac2855eb57ff131d0b313d5e9d"
|
Url = https://preview.redd.it/d5yno653zf7d1.jpg?width=640&crop=smart&auto=webp&s=5064d1caec3c12ac2855eb57ff131d0b313d5e9d"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`GenerateOutput GIVEN options.json is true, EXPECT output to be returned as JSON 1`] = `"{"Archived":false,"Downs":0,"Hidden":false,"Permalink":"/r/Rabbits/comments/1dj8pbt/this_is_my_ms_bear/","Subreddit":"Rabbits","SubredditSubscribers":654751,"Title":"This is my Ms Bear!","Ups":17,"Url":"https://preview.redd.it/d5yno653zf7d1.jpg?width=640&crop=smart&auto=webp&s=5064d1caec3c12ac2855eb57ff131d0b313d5e9d"}"`;
|
exports[`GenerateOutput GIVEN options.json is true, EXPECT output to be returned as JSON 1`] = `"{"Archived":false,"Author":"author","Downs":0,"Hidden":false,"Permalink":"/r/Rabbits/comments/1dj8pbt/this_is_my_ms_bear/","Subreddit":"Rabbits","SubredditSubscribers":654751,"Title":"This is my Ms Bear!","Ups":17,"Url":"https://preview.redd.it/d5yno653zf7d1.jpg?width=640&crop=smart&auto=webp&s=5064d1caec3c12ac2855eb57ff131d0b313d5e9d"}"`;
|
||||||
|
|
||||||
exports[`GenerateOutput GIVEN options.queryMetadata is supplied, EXPECT query metadata to be added 1`] = `
|
exports[`GenerateOutput GIVEN options.queryMetadata is supplied, EXPECT query metadata to be added 1`] = `
|
||||||
"Archived = false
|
"Archived = false
|
||||||
|
Author = author
|
||||||
Downvotes = 0
|
Downvotes = 0
|
||||||
Hidden = false
|
Hidden = false
|
||||||
Permalink = /r/Rabbits/comments/1dj8pbt/this_is_my_ms_bear/
|
Permalink = /r/Rabbits/comments/1dj8pbt/this_is_my_ms_bear/
|
||||||
|
|
|
@ -14,6 +14,7 @@ describe("GenerateOutput", () => {
|
||||||
},
|
},
|
||||||
Result: {
|
Result: {
|
||||||
Archived: false,
|
Archived: false,
|
||||||
|
Author: 'author',
|
||||||
Downs: 0,
|
Downs: 0,
|
||||||
Hidden: false,
|
Hidden: false,
|
||||||
Permalink: "/r/Rabbits/comments/1dj8pbt/this_is_my_ms_bear/",
|
Permalink: "/r/Rabbits/comments/1dj8pbt/this_is_my_ms_bear/",
|
||||||
|
@ -45,6 +46,7 @@ describe("GenerateOutput", () => {
|
||||||
},
|
},
|
||||||
Result: {
|
Result: {
|
||||||
Archived: false,
|
Archived: false,
|
||||||
|
Author: 'author',
|
||||||
Downs: 0,
|
Downs: 0,
|
||||||
Hidden: false,
|
Hidden: false,
|
||||||
Permalink: "/r/Rabbits/comments/1dj8pbt/this_is_my_ms_bear/",
|
Permalink: "/r/Rabbits/comments/1dj8pbt/this_is_my_ms_bear/",
|
||||||
|
@ -78,6 +80,7 @@ describe("GenerateOutput", () => {
|
||||||
},
|
},
|
||||||
Result: {
|
Result: {
|
||||||
Archived: false,
|
Archived: false,
|
||||||
|
Author: 'author',
|
||||||
Downs: 0,
|
Downs: 0,
|
||||||
Hidden: false,
|
Hidden: false,
|
||||||
Permalink: "/r/Rabbits/comments/1dj8pbt/this_is_my_ms_bear/",
|
Permalink: "/r/Rabbits/comments/1dj8pbt/this_is_my_ms_bear/",
|
||||||
|
|
|
@ -20,6 +20,7 @@ describe('randomBunny', () => {
|
||||||
{
|
{
|
||||||
data: {
|
data: {
|
||||||
archived: false,
|
archived: false,
|
||||||
|
author: 'author',
|
||||||
downs: 0,
|
downs: 0,
|
||||||
hidden: false,
|
hidden: false,
|
||||||
permalink: '/r/Rabbits/comments/12pa5te/someone_told_pickles_its_monday_internal_fury/',
|
permalink: '/r/Rabbits/comments/12pa5te/someone_told_pickles_its_monday_internal_fury/',
|
||||||
|
@ -52,6 +53,7 @@ describe('randomBunny', () => {
|
||||||
{
|
{
|
||||||
data: {
|
data: {
|
||||||
archived: false,
|
archived: false,
|
||||||
|
author: 'author',
|
||||||
downs: 0,
|
downs: 0,
|
||||||
hidden: false,
|
hidden: false,
|
||||||
permalink: '/r/Rabbits/comments/12pa5te/someone_told_pickles_its_monday_internal_fury/',
|
permalink: '/r/Rabbits/comments/12pa5te/someone_told_pickles_its_monday_internal_fury/',
|
||||||
|
@ -137,6 +139,7 @@ describe('randomBunny', () => {
|
||||||
{
|
{
|
||||||
data: {
|
data: {
|
||||||
archived: false,
|
archived: false,
|
||||||
|
author: 'author',
|
||||||
downs: 0,
|
downs: 0,
|
||||||
hidden: false,
|
hidden: false,
|
||||||
permalink: '/r/Rabbits/comments/12pa5te/someone_told_pickles_its_monday_internal_fury/',
|
permalink: '/r/Rabbits/comments/12pa5te/someone_told_pickles_its_monday_internal_fury/',
|
||||||
|
@ -173,6 +176,7 @@ describe('randomBunny', () => {
|
||||||
{
|
{
|
||||||
data: {
|
data: {
|
||||||
archived: false,
|
archived: false,
|
||||||
|
author: 'author',
|
||||||
downs: 0,
|
downs: 0,
|
||||||
hidden: false,
|
hidden: false,
|
||||||
permalink: '/r/Rabbits/comments/12pa5te/someone_told_pickles_its_monday_internal_fury/',
|
permalink: '/r/Rabbits/comments/12pa5te/someone_told_pickles_its_monday_internal_fury/',
|
||||||
|
@ -209,6 +213,7 @@ describe('randomBunny', () => {
|
||||||
{
|
{
|
||||||
data: {
|
data: {
|
||||||
archived: false,
|
archived: false,
|
||||||
|
author: 'author',
|
||||||
downs: 0,
|
downs: 0,
|
||||||
hidden: false,
|
hidden: false,
|
||||||
permalink: '/r/Rabbits/comments/12pa5te/someone_told_pickles_its_monday_internal_fury/',
|
permalink: '/r/Rabbits/comments/12pa5te/someone_told_pickles_its_monday_internal_fury/',
|
||||||
|
@ -244,6 +249,7 @@ describe('randomBunny', () => {
|
||||||
{
|
{
|
||||||
data: {
|
data: {
|
||||||
archived: false,
|
archived: false,
|
||||||
|
author: 'author',
|
||||||
downs: 0,
|
downs: 0,
|
||||||
hidden: false,
|
hidden: false,
|
||||||
permalink: '/r/Rabbits/comments/12pa5te/someone_told_pickles_its_monday_internal_fury/',
|
permalink: '/r/Rabbits/comments/12pa5te/someone_told_pickles_its_monday_internal_fury/',
|
||||||
|
@ -276,6 +282,7 @@ describe('randomBunny', () => {
|
||||||
{
|
{
|
||||||
data: {
|
data: {
|
||||||
archived: false,
|
archived: false,
|
||||||
|
author: 'author',
|
||||||
downs: 0,
|
downs: 0,
|
||||||
hidden: false,
|
hidden: false,
|
||||||
permalink: '/r/Rabbits/comments/12pa5te/someone_told_pickles_its_monday_internal_fury/',
|
permalink: '/r/Rabbits/comments/12pa5te/someone_told_pickles_its_monday_internal_fury/',
|
||||||
|
@ -311,6 +318,7 @@ describe('randomBunny', () => {
|
||||||
{
|
{
|
||||||
data: {
|
data: {
|
||||||
archived: false,
|
archived: false,
|
||||||
|
author: 'author',
|
||||||
downs: 0,
|
downs: 0,
|
||||||
hidden: false,
|
hidden: false,
|
||||||
permalink: '/r/Rabbits/comments/12pa5te/someone_told_pickles_its_monday_internal_fury/',
|
permalink: '/r/Rabbits/comments/12pa5te/someone_told_pickles_its_monday_internal_fury/',
|
||||||
|
|
Loading…
Reference in a new issue