mirror of
https://github.com/tiennm99/is-a-dev.git
synced 2026-10-19 18:15:44 +00:00
Merge branch 'refactor/switch-to-bun' of github.com:is-a-dev/register into feat/support-aaaa-records
This commit is contained in:
11 files changed
+40
-64
No files matched your search
File renamed without changes.
@@ -1,5 +1,5 @@
|
|||||||
name: Checks
|
name: Checks
|
||||||
on: [pull_request]
|
on: [pull_request, workflow_dispatch]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
validation:
|
validation:
|
||||||
@@ -9,15 +9,8 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
ref: ${{ github.event.pull_request.head.sha }}
|
ref: ${{ github.event.pull_request.head.sha }}
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- name: Setup node v16
|
- uses: oven-sh/setup-bun@v1
|
||||||
uses: actions/setup-node@v1
|
|
||||||
with:
|
with:
|
||||||
node-version: '16'
|
bun-version: 1.0.0
|
||||||
- name: Install dependencies
|
- run: bun install
|
||||||
uses: borales/actions-yarn@v2.0.0
|
- run: bun test
|
||||||
with:
|
|
||||||
cmd: install --ignore-engines --frozen-lockfile
|
|
||||||
- name: Run tests
|
|
||||||
uses: borales/actions-yarn@v2.0.0
|
|
||||||
with:
|
|
||||||
cmd: test
|
|
||||||
@@ -12,16 +12,15 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- uses: borales/actions-yarn@v2.0.0
|
- uses: oven-sh/setup-bun@v1
|
||||||
with:
|
with:
|
||||||
cmd: install --ignore-engines
|
bun-version: 1.0.0
|
||||||
- name: Running tests
|
- run: bun install
|
||||||
uses: borales/actions-yarn@v2.0.0
|
- run: bun test
|
||||||
with:
|
|
||||||
cmd: test
|
|
||||||
- name: Publishing records
|
- name: Publishing records
|
||||||
env:
|
env:
|
||||||
CI: 1
|
CI: 1
|
||||||
|
NODE_ENV: production
|
||||||
ENV: production
|
ENV: production
|
||||||
DOMAIN_USER: ${{ secrets.DOMAIN_USER }}
|
DOMAIN_USER: ${{ secrets.DOMAIN_USER }}
|
||||||
DOMAIN_API_KEY: ${{ secrets.DOMAIN_API_KEY }}
|
DOMAIN_API_KEY: ${{ secrets.DOMAIN_API_KEY }}
|
||||||
@@ -29,6 +28,4 @@ jobs:
|
|||||||
DOMAIN_API_PORT: ${{ secrets.DOMAIN_API_PORT }}
|
DOMAIN_API_PORT: ${{ secrets.DOMAIN_API_PORT }}
|
||||||
DOMAIN_DOMAIN: ${{ secrets.DOMAIN_DOMAIN }}
|
DOMAIN_DOMAIN: ${{ secrets.DOMAIN_DOMAIN }}
|
||||||
DOMAIN_HOST_IP: ${{ secrets.DOMAIN_HOST_IP }}
|
DOMAIN_HOST_IP: ${{ secrets.DOMAIN_HOST_IP }}
|
||||||
uses: borales/actions-yarn@v2.0.0
|
run: bun run publish-records
|
||||||
with:
|
|
||||||
cmd: publish-records
|
|
||||||
+1
-1
@@ -1,3 +1,3 @@
|
|||||||
node_modules/
|
node_modules/
|
||||||
*.env.*
|
*.env.production
|
||||||
*.log
|
*.log
|
||||||
+1
-2
@@ -3,11 +3,10 @@ let
|
|||||||
inherit (nixpkgs) pkgs;
|
inherit (nixpkgs) pkgs;
|
||||||
|
|
||||||
nixPackages = with pkgs; [
|
nixPackages = with pkgs; [
|
||||||
nodejs-18_x
|
|
||||||
yarn
|
yarn
|
||||||
docker-compose
|
docker-compose
|
||||||
dnsutils
|
dnsutils
|
||||||
#certbot
|
bun
|
||||||
];
|
];
|
||||||
in
|
in
|
||||||
pkgs.stdenv.mkDerivation {
|
pkgs.stdenv.mkDerivation {
|
||||||
|
|||||||
+3
-11
@@ -3,28 +3,20 @@
|
|||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"description": "Register *.is-a.dev domains for free",
|
"description": "Register *.is-a.dev domains for free",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "ENV=test jest",
|
|
||||||
"lint": "eslint utils scripts domains --ext .json,.js",
|
"lint": "eslint utils scripts domains --ext .json,.js",
|
||||||
"publish-records": "node ./scripts/register-domains.js",
|
"publish-records": "bun run -b ./scripts/register-domains.js",
|
||||||
"dc": "docker-compose -p is-a-dev",
|
"dc": "docker-compose -p is-a-dev",
|
||||||
"dc:start": "yarn dc up",
|
"dc:start": "bun run dc up",
|
||||||
"dc:shell": "yarn dc run dev /bin/bash"
|
"dc:shell": "bun run dc run dev /bin/bash"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/is-a-dev/register"
|
"url": "https://github.com/is-a-dev/register"
|
||||||
},
|
},
|
||||||
"keywords": [
|
|
||||||
"subdomain"
|
|
||||||
],
|
|
||||||
"author": "Akshay Nair <phenax5@gmail.com>",
|
"author": "Akshay Nair <phenax5@gmail.com>",
|
||||||
"license": "GPL-3.0",
|
"license": "GPL-3.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"dotenv": "^8.2.0",
|
|
||||||
"is-ip": "^5.0.1",
|
"is-ip": "^5.0.1",
|
||||||
"jest": "^26.4.2",
|
|
||||||
"node-fetch": "^2.6.1",
|
|
||||||
"qs": "^6.9.4",
|
|
||||||
"ramda": "^0.27.1"
|
"ramda": "^0.27.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
@@ -204,18 +204,18 @@ describe('Domain service', () => {
|
|||||||
{ name: 'c', type: 'MX', address: 'foobar.com', priority: 2 },
|
{ name: 'c', type: 'MX', address: 'foobar.com', priority: 2 },
|
||||||
]);
|
]);
|
||||||
|
|
||||||
expect(addZone).toBeCalledTimes(1);
|
expect(addZone).toHaveBeenCalledTimes(1);
|
||||||
expect(getRecordCalls(addZone)).toEqual([
|
expect(getRecordCalls(addZone)).toEqual([
|
||||||
{ name: 'c', type: 'A', address: '12.131321.213' },
|
{ name: 'c', type: 'A', address: '12.131321.213' },
|
||||||
]);
|
]);
|
||||||
|
|
||||||
expect(addEmail).toBeCalledTimes(1);
|
expect(addEmail).toHaveBeenCalledTimes(1);
|
||||||
expect(getRecordCalls(addEmail)).toEqual([
|
expect(getRecordCalls(addEmail)).toEqual([
|
||||||
{ domain: 'c.is-a.dev', exchanger: 'foobar.com', priority: 2 },
|
{ domain: 'c.is-a.dev', exchanger: 'foobar.com', priority: 2 },
|
||||||
]);
|
]);
|
||||||
|
|
||||||
expect(removeZone).toBeCalledTimes(0);
|
expect(removeZone).toHaveBeenCalledTimes(0);
|
||||||
expect(removeEmail).toBeCalledTimes(0);
|
expect(removeEmail).toHaveBeenCalledTimes(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should update matching host and set it', async () => {
|
it('should update matching host and set it', async () => {
|
||||||
@@ -231,11 +231,11 @@ describe('Domain service', () => {
|
|||||||
{ name: 'b', type: 'CNAME', address: 'googoogaga' },
|
{ name: 'b', type: 'CNAME', address: 'googoogaga' },
|
||||||
]);
|
]);
|
||||||
|
|
||||||
expect(addZone).toBeCalledTimes(1);
|
expect(addZone).toHaveBeenCalledTimes(1);
|
||||||
expect(getRecordCalls(addZone)).toEqual([
|
expect(getRecordCalls(addZone)).toEqual([
|
||||||
{ name: 'b', type: 'CNAME', address: 'googoogaga' },
|
{ name: 'b', type: 'CNAME', address: 'googoogaga' },
|
||||||
]);
|
]);
|
||||||
expect(removeZone).toBeCalledTimes(1);
|
expect(removeZone).toHaveBeenCalledTimes(1);
|
||||||
expect(getRecordCalls(removeZone)).toEqual([
|
expect(getRecordCalls(removeZone)).toEqual([
|
||||||
{ line: 2 },
|
{ line: 2 },
|
||||||
]);
|
]);
|
||||||
@@ -256,12 +256,12 @@ describe('Domain service', () => {
|
|||||||
{ name: 'b', type: 'CNAME', address: 'farboo' },
|
{ name: 'b', type: 'CNAME', address: 'farboo' },
|
||||||
]);
|
]);
|
||||||
|
|
||||||
expect(addZone).toBeCalledTimes(2);
|
expect(addZone).toHaveBeenCalledTimes(2);
|
||||||
expect(getRecordCalls(addZone)).toEqual([
|
expect(getRecordCalls(addZone)).toEqual([
|
||||||
{ name: 'b', type: 'CNAME', address: 'googoogaga' },
|
{ name: 'b', type: 'CNAME', address: 'googoogaga' },
|
||||||
{ name: 'b', type: 'CNAME', address: 'farboo' },
|
{ name: 'b', type: 'CNAME', address: 'farboo' },
|
||||||
]);
|
]);
|
||||||
expect(removeZone).toBeCalledTimes(2);
|
expect(removeZone).toHaveBeenCalledTimes(2);
|
||||||
expect(getRecordCalls(removeZone)).toEqual([
|
expect(getRecordCalls(removeZone)).toEqual([
|
||||||
{ line: 2 },
|
{ line: 2 },
|
||||||
{ line: 3 },
|
{ line: 3 },
|
||||||
@@ -300,34 +300,34 @@ describe('Domain service', () => {
|
|||||||
{ name: 'a', type: 'MX', address: 'example.com', priority: 20 },
|
{ name: 'a', type: 'MX', address: 'example.com', priority: 20 },
|
||||||
]);
|
]);
|
||||||
|
|
||||||
expect(addZone).toBeCalledTimes(3);
|
expect(addZone).toHaveBeenCalledTimes(3);
|
||||||
expect(getRecordCalls(addZone)).toEqual([
|
expect(getRecordCalls(addZone)).toEqual([
|
||||||
{ name: 'a', type: 'CNAME', address: 'boo' },
|
{ name: 'a', type: 'CNAME', address: 'boo' },
|
||||||
{ name: 'b', type: 'A', address: '3' },
|
{ name: 'b', type: 'A', address: '3' },
|
||||||
{ name: 'd', type: 'CNAME', address: 'helo.com' },
|
{ name: 'd', type: 'CNAME', address: 'helo.com' },
|
||||||
]);
|
]);
|
||||||
expect(removeZone).toBeCalledTimes(1);
|
expect(removeZone).toHaveBeenCalledTimes(1);
|
||||||
expect(getRecordCalls(removeZone)).toEqual([
|
expect(getRecordCalls(removeZone)).toEqual([
|
||||||
{ line: 1 },
|
{ line: 1 },
|
||||||
]);
|
]);
|
||||||
|
|
||||||
expect(addEmail).toBeCalledTimes(1);
|
expect(addEmail).toHaveBeenCalledTimes(1);
|
||||||
expect(getRecordCalls(addEmail)).toEqual([
|
expect(getRecordCalls(addEmail)).toEqual([
|
||||||
{ domain: 'a.is-a.dev', exchanger: 'example.com', priority: 20 },
|
{ domain: 'a.is-a.dev', exchanger: 'example.com', priority: 20 },
|
||||||
]);
|
]);
|
||||||
expect(removeEmail).toBeCalledTimes(2);
|
expect(removeEmail).toHaveBeenCalledTimes(2);
|
||||||
expect(getRecordCalls(removeEmail)).toEqual([
|
expect(getRecordCalls(removeEmail)).toEqual([
|
||||||
{ domain: 'c.is-a.dev', exchanger: 'mx1.hello.com', priority: 20 },
|
{ domain: 'c.is-a.dev', exchanger: 'mx1.hello.com', priority: 20 },
|
||||||
{ domain: 'b.is-a.dev', exchanger: 'foo.bar', priority: 20 },
|
{ domain: 'b.is-a.dev', exchanger: 'foo.bar', priority: 20 },
|
||||||
]);
|
]);
|
||||||
|
|
||||||
expect(addRedir).toBeCalledTimes(3);
|
expect(addRedir).toHaveBeenCalledTimes(3);
|
||||||
expect(getRecordCalls(addRedir)).toEqual([
|
expect(getRecordCalls(addRedir)).toEqual([
|
||||||
{ domain: `b.${DOMAIN_DOMAIN}`, type: 'permanent', redirect: 'https://wowow.com' },
|
{ domain: `b.${DOMAIN_DOMAIN}`, type: 'permanent', redirect: 'https://wowow.com' },
|
||||||
{ domain: `d.${DOMAIN_DOMAIN}`, type: 'permanent', redirect: 'https://hhh.com' },
|
{ domain: `d.${DOMAIN_DOMAIN}`, type: 'permanent', redirect: 'https://hhh.com' },
|
||||||
{ domain: `x.${DOMAIN_DOMAIN}`, type: 'permanent', redirect: 'https://example69.com' },
|
{ domain: `x.${DOMAIN_DOMAIN}`, type: 'permanent', redirect: 'https://example69.com' },
|
||||||
]);
|
]);
|
||||||
expect(removeRedir).toBeCalledTimes(2);
|
expect(removeRedir).toHaveBeenCalledTimes(2);
|
||||||
expect(getRecordCalls(removeRedir)).toEqual([
|
expect(getRecordCalls(removeRedir)).toEqual([
|
||||||
{ domain: `b.${DOMAIN_DOMAIN}` },
|
{ domain: `b.${DOMAIN_DOMAIN}` },
|
||||||
{ domain: `x.${DOMAIN_DOMAIN}` },
|
{ domain: `x.${DOMAIN_DOMAIN}` },
|
||||||
|
|||||||
@@ -87,10 +87,10 @@ describe('registerDomains', () => {
|
|||||||
const domainService = mockDS({ zones: remoteHosts, redirections: remoteRedirections });
|
const domainService = mockDS({ zones: remoteHosts, redirections: remoteRedirections });
|
||||||
await registerDomains({ getDomains: async () => localHosts, domainService });
|
await registerDomains({ getDomains: async () => localHosts, domainService });
|
||||||
|
|
||||||
expect(addZone).toBeCalledTimes(0);
|
expect(addZone).toHaveBeenCalledTimes(0);
|
||||||
expect(removeZone).toBeCalledTimes(1);
|
expect(removeZone).toHaveBeenCalledTimes(1);
|
||||||
expect(addRedir).toBeCalledTimes(0);
|
expect(addRedir).toHaveBeenCalledTimes(0);
|
||||||
expect(removeRedir).toBeCalledTimes(0);
|
expect(removeRedir).toHaveBeenCalledTimes(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should add the new set hosts', async () => {
|
it('should add the new set hosts', async () => {
|
||||||
@@ -111,10 +111,10 @@ describe('registerDomains', () => {
|
|||||||
const domainService = mockDS({ zones: remoteHosts, redirections: remoteRedirections });
|
const domainService = mockDS({ zones: remoteHosts, redirections: remoteRedirections });
|
||||||
await registerDomains({ getDomains: async () => localHosts, domainService });
|
await registerDomains({ getDomains: async () => localHosts, domainService });
|
||||||
|
|
||||||
expect(addZone).toBeCalledTimes(1);
|
expect(addZone).toHaveBeenCalledTimes(1);
|
||||||
expect(removeZone).toBeCalledTimes(0);
|
expect(removeZone).toHaveBeenCalledTimes(0);
|
||||||
expect(addRedir).toBeCalledTimes(2);
|
expect(addRedir).toHaveBeenCalledTimes(2);
|
||||||
expect(removeRedir).toBeCalledTimes(1);
|
expect(removeRedir).toHaveBeenCalledTimes(1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
+1
-5
@@ -1,10 +1,6 @@
|
|||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
const { ENV = 'test', CI } = process.env;
|
const { NODE_ENV: ENV = 'test' } = process.env;
|
||||||
|
|
||||||
if (!CI) {
|
|
||||||
require('dotenv').config({ path: path.resolve(`.env.${ENV}`) });
|
|
||||||
}
|
|
||||||
|
|
||||||
const {
|
const {
|
||||||
DOMAIN_USER,
|
DOMAIN_USER,
|
||||||
|
|||||||
+1
-2
@@ -1,6 +1,5 @@
|
|||||||
const R = require('ramda');
|
const R = require('ramda');
|
||||||
const fetch = require('node-fetch');
|
const qs = require('querystring');
|
||||||
const qs = require('qs');
|
|
||||||
const { DOMAIN_API_HOST, DOMAIN_API_PORT, DOMAIN_USER, DOMAIN_API_KEY, DOMAIN_DOMAIN } = require('../constants');
|
const { DOMAIN_API_HOST, DOMAIN_API_PORT, DOMAIN_USER, DOMAIN_API_KEY, DOMAIN_DOMAIN } = require('../constants');
|
||||||
|
|
||||||
const CpanelClient = (options) => {
|
const CpanelClient = (options) => {
|
||||||
|
|||||||
Reference in new issue
Block a user