Skip to content

Commit

Permalink
Merge pull request #55 from RizkyRajitha/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
RizkyRajitha authored Nov 16, 2021
2 parents 55217f1 + 2b858d2 commit acaeb17
Show file tree
Hide file tree
Showing 50 changed files with 2,332 additions and 818 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Code-Coverage
name: Code Coverage

on: [push, pull_request]

Expand Down Expand Up @@ -26,18 +26,18 @@ jobs:
# Maps tcp port 5432 on service container to the host
- 5432:5432

strategy:
matrix:
node-version: [14.x]
# strategy:
# matrix:
# node-version: [14.x]

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up Node.js ${{ matrix.node-version }}
- name: Set up Node.js 14.x
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
node-version: 14.x

- name: Cache node modules
uses: actions/cache@v2
Expand Down
29 changes: 29 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Publish
# Only trigger, when the build workflow succeeded

on:
workflow_run:
workflows: ["Code Coverage"]
branches: [master]
types:
- completed
# - requested
jobs:
Publish:
if: ${{ github.event.workflow_run.conclusion == 'success' }}

runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Build docker container
run: docker build . -t ghcr.io/$(echo $GITHUB_ACTOR | tr '[:upper:]' '[:lower:]')/linkin:latest -t ghcr.io/$(echo $GITHUB_ACTOR | tr '[:upper:]' '[:lower:]')/linkin:$(echo $GITHUB_SHA | head -c7)

- name: Login to docker
run: echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{github.actor}} --password-stdin

- name: Push
run: docker push ghcr.io/$(echo $GITHUB_ACTOR | tr '[:upper:]' '[:lower:]')/linkin:latest
# docker build . -t ghcr.io/aa/linkin:latest -t ghcr.io/aa/linkin:${echo $GITHUB_SHA | head -c7}
24 changes: 16 additions & 8 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,12 @@ Linkin has 2 main branches

1. [master](https://github.com/RizkyRajitha/linkin/tree/master) branch - will have the code from the latest release. only updates on a release.
2. [dev](https://github.com/RizkyRajitha/linkin/tree/dev) branch - all the development carries out in this branch. the latest code will be available in this branch, **all the pull requests should be made to dev branch** since prs could be tested and modified for the final release phase.
other than the above branches there can feature specific branches for the continence.
other than the above branches there can feature specific branches for the continence.

## Making pull request

when making a pull request please create your feature branch using the **[dev](https://github.com/RizkyRajitha/linkin/tree/dev)** branch (`checkout using dev branch`), and develop in it locally. avoid installing additional dependencies unless clarified through a maintainer. make the pr to the **[dev](https://github.com/RizkyRajitha/linkin/tree/dev)** branch.


## File Structure

```
Expand Down Expand Up @@ -239,7 +238,8 @@ there are 6 forms inside the `Formwrapper`.form has been divided into this manne
3. Colors (form that holds color details) [colorform.js](./components/colorform.js)
4. Fonts (form that holds font details) [fontform.js](./components/fontform.js)
5. Link Data (a form that configures links and their respective details, this form have it's how API posing to facilitate live refresh in links) [linksform.js](./components/linksform.js)
6. Updated Password (a form that updates the password) [passwordchangeform.js](./components/passwordchangeform.js)
6. Social Data (a form that configures **social** links and their respective details, this form have it's how API posing to facilitate live refresh in links) [socialform.js](./components/socialform.js)
7. Updated Password (a form that updates the password) [passwordchangeform.js](./components/passwordchangeform.js)

#### Preview

Expand All @@ -257,16 +257,24 @@ Linkin levarages next js built-in [api-routes](https://nextjs.org/docs/api-route
this removes the requirement of additional API deployment, making Linkin cleaner and easier to deploy.
all the API routes live in [/pages/api/](./pages/api/) directory.

Linkin has 8 API routes
Linkin has 12 API routes:

1. login [login.js](./pages/api/login.js)
2. logout [logout.js](./pages/api/logout.js)
3. changepassword [changepassword.js](./pages/api/changepassword.js)
4. updatepagedata [updatepagedata.js](./pages/api/updatepagedata.js)
5. insertpagelinks [insertpagelinks.js](./pages/api/insertpagelinks.js)
6. updatepagelinks [updatepagelinks.js](./pages/api/updatepagelinks.js)
7. deletepagelink [deletepagelink.js](./pages/api/deletepagelink.js)
8. reorderlinks [reorderlinks.js](./pages/api/reorderlinks.js)
5. insertlinks
- For pages form: [insertlinks.js](./pages/api/pages/insertlinks.js)
- For social form: [insertlinks.js](./pages/api/social/insertlinks.js)
6. updatelinks
- For pages form: [updatelinks.js](./pages/api/pages/updatelinks.js)
- For social form: [updatelinks.js](./pages/api/social/updatelinks.js)
7. deletelink
- For pages form: [deletelink.js](./pages/api/pages/deletelink.js)
- For social form: [deletelink.js](./pages/api/social/deletelink.js)
8. reorderlinks
- For pages form [reorderlinks.js](./pages/api/pages/reorderlinks.js)
- For social form [reorderlinks.js](./pages/api/social/reorderlinks.js)

| API | method | data | response |
| --------------- | ------ | ----------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@

## Linkin is a customizable self-hosted link tree application.

### 100% Free and Open Source 💯
### Free and Open Source 💯

### Self Hosted, you own your data 💽

### Customize your link tree with few clicks with a feature-rich dashboard 🤖
### Customize your link tree with few clicks using a feature-rich dashboard 🤖

### SEO friendly design built using Next js 🕸️

### Supports 3 one-click deploy hosting providers 🚀
### Supports one-click deploy using multiple cloud providers 🚀

<br>

Expand Down
83 changes: 57 additions & 26 deletions __tests__/prismalinkdata.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const path = require("path");
const Prisma = require("../db/dbconprisma");
const { default: Prisma } = require("../db/dbconprisma");

require("dotenv").config({
path: path.join(__dirname, "../", ".env"),
Expand All @@ -10,21 +10,37 @@ const {
insertPageLinks,
updateLink,
deleteLink,
reorderLinks,
} = require("../lib/dbfuncprisma");

describe("Test Link data", () => {
beforeAll(async () => {
await Prisma.linkdata.deleteMany();
await Prisma.linkdata.create({
data: {
id: 1,
pagedataid: 1,
iconClass: "fas fa-link",
displayText: "Welcome to LinkIn",
linkUrl: "https://github.com/RizkyRajitha/linkin",
bgColor: "#2C6BED",
active: true,
},
});
});

beforeEach(() => {
jest.spyOn(console, "log").mockImplementation(() => {});
});

afterAll(async () => {
await Prisma.default.$disconnect();
await Prisma.$disconnect();
});

test("get link data", async () => {
let { linkData } = await getLinkData();
//console.info(linkData);

const expectedLink = {
id: 1,
pagedataid: 1,
iconClass: "fas fa-link",
displayText: "Welcome to LinkIn",
Expand All @@ -40,9 +56,8 @@ describe("Test Link data", () => {

test("get link data without active", async () => {
let { linkData } = await getLinkData(false);
//console.log(linkData);

const expectedLink = {
id: 1,
pagedataid: 1,
iconClass: "fas fa-link",
displayText: "Welcome to LinkIn",
Expand All @@ -59,7 +74,6 @@ describe("Test Link data", () => {
test("get link data without active", async () => {
let { linkData } = await getLinkData(false);
const expectedLink = {
id: 1,
pagedataid: 1,
iconClass: "fas fa-link",
displayText: "Welcome to LinkIn",
Expand Down Expand Up @@ -87,19 +101,17 @@ describe("Test Link data", () => {
await insertPageLinks(linkTobeinserted);
let updatedLinkData = await getLinkData();

//console.info(updatedLinkData);

expect(updatedLinkData.linkData).toMatchObject([
...beforeUpdateLinkData.linkData,
linkTobeinserted,
]);
});

test("delete link data ", async () => {
let beforeUpdateLinkData = await getLinkData();
let beforeUpdateLinkData = await (await getLinkData()).linkData;
//console.info(beforeUpdateLinkData.linkData[1].id);

let delelement = beforeUpdateLinkData.linkData.filter((ele) => {
let delelement = beforeUpdateLinkData.filter((ele) => {
return ele.id !== 1;
});

Expand All @@ -108,9 +120,11 @@ describe("Test Link data", () => {

//console.info(updatedLinkData);

expect(updatedLinkData.linkData).toMatchObject([
beforeUpdateLinkData.linkData[0],
]);
expectedLink = beforeUpdateLinkData.filter((ele) => {
return ele.id === 1;
});

expect(updatedLinkData.linkData[0]).toMatchObject(expectedLink[0]);
});

test("update link data ", async () => {
Expand All @@ -136,25 +150,42 @@ describe("Test Link data", () => {
// });
});

test("revert updated link data ", async () => {
const linkTobeUpdated = {
id: 1,
test("reorder links", async () => {
await insertPageLinks({
pagedataid: 1,
iconClass: "fas fa-link",
displayText: "Welcome to LinkIn",
displayText: "link2",
linkUrl: "https://github.com/RizkyRajitha/linkin",
bgColor: "#2C6BED",
active: true,
};
});

await updateLink(linkTobeUpdated);
let updatedLinkData = await getLinkData();
let orderList = await (
await getLinkData()
).linkData.map((item) => {
return { id: item.id, orderIndex: item.orderIndex };
});

//console.info(updatedLinkData);
// console.info(orderList);

expect(updatedLinkData.linkData[0]).toMatchObject(linkTobeUpdated);
// linkData.forEach((element) => {
// expect(element).toMatchObject(expectedLink);
// });
let reOrderList = orderList.map((item, index) => {
return { id: item.id, orderIndex: index };
});

await reorderLinks(reOrderList);

let updatedOrderList = await (
await getLinkData()
).linkData.map((item) => {
return { orderIndex: item.orderIndex };
});

// expect(updatedLinkData.linkData[0]).toMatchObject(linkTobeUpdated);

let expectedOrderList = [{ orderIndex: 0 }, { orderIndex: 1 }];

expectedOrderList.forEach((element, index) => {
expect(element).toMatchObject(updatedOrderList[index]);
});
});
});
Loading

1 comment on commit acaeb17

@vercel
Copy link

@vercel vercel bot commented on acaeb17 Nov 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.