Skip to content

Commit 473bac1

Browse files
authored
Merge pull request #1 from Zonos/build/init
Build/init
2 parents a9a067e + 6616329 commit 473bac1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+52048
-0
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dist

.eslintrc.js

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
/**
2+
* @type {import("eslint").Linter.Config}
3+
*/
4+
module.exports = {
5+
extends: ['airbnb/base', 'plugin:import/typescript', 'prettier'],
6+
plugins: [
7+
'jest',
8+
'prettier',
9+
'simple-import-sort',
10+
'@typescript-eslint',
11+
'deprecation',
12+
],
13+
parser: '@typescript-eslint/parser',
14+
parserOptions: {
15+
ecmaVersion: 2020,
16+
sourceType: 'module',
17+
ecmaFeatures: {
18+
jsx: true,
19+
},
20+
/**
21+
* Listen to typescript configuration
22+
*/
23+
project: './tsconfig.json',
24+
},
25+
settings: {
26+
'import/resolver': {
27+
node: {
28+
paths: [__dirname],
29+
},
30+
},
31+
},
32+
overrides: [
33+
{
34+
/**
35+
* Disable no-undef on typescript file since the check it provides are already provided by Typescript without the need for configuration
36+
* Refs: https://github.com/typescript-eslint/typescript-eslint/blob/main/docs/linting/TROUBLESHOOTING.md#i-get-errors-from-the-no-undef-rule-about-global-variables-not-being-defined-even-though-there-are-no-typescript-errors
37+
*/
38+
files: ['*.ts', '*.mts', '*.cts', '*.tsx'],
39+
rules: {
40+
'no-undef': 'off',
41+
},
42+
},
43+
{
44+
files: ['*.graphql.*'],
45+
rules: {
46+
'@typescript-eslint/no-unused-vars': 'off',
47+
},
48+
},
49+
],
50+
rules: {
51+
/**
52+
* Report deprecated variables (This is helpful to find deprecated variables are being used)
53+
* @link https://www.npmjs.com/package/eslint-plugin-deprecation
54+
* */
55+
'deprecation/deprecation': 'warn',
56+
'import/no-extraneous-dependencies': [
57+
'error',
58+
/** Allow test files to import library from devDependencies */
59+
{
60+
devDependencies: ['**/*.test.ts', '**/*.test.tsx', 'build-utils/**'],
61+
},
62+
],
63+
/**
64+
* Report all unnecessary chaining "?".
65+
* @description https://github.com/typescript-eslint/typescript-eslint/issues/1641 (Issue description)
66+
* @info https://typescript-eslint.io/rules/no-unnecessary-condition/ (Eslint rule detail)
67+
* */
68+
'@typescript-eslint/no-unnecessary-condition': 'warn',
69+
'@typescript-eslint/no-explicit-any': 'error',
70+
camelcase: 'off',
71+
'no-unused-vars': 'off', // Disable the base rule it can report incorrect errors
72+
'no-use-before-define': 'off',
73+
'@typescript-eslint/no-use-before-define': [
74+
'error',
75+
{ typedefs: false }, // disable for typing definition
76+
],
77+
'no-restricted-exports': 'off',
78+
/** @link https://eslint.org/docs/latest/rules/no-unused-vars#ignorerestsiblings */
79+
'@typescript-eslint/no-unused-vars': [
80+
'warn',
81+
{ ignoreRestSiblings: true, argsIgnorePattern: '^_' },
82+
],
83+
'import/extensions': [
84+
'error',
85+
'ignorePackages',
86+
{
87+
js: 'never',
88+
jsx: 'never',
89+
ts: 'never',
90+
tsx: 'never',
91+
},
92+
],
93+
'import/no-unresolved': 'off', // Typescript takes care of this
94+
'import/prefer-default-export': 'off',
95+
'import/no-internal-modules': [
96+
'warn',
97+
{
98+
forbid: [
99+
/* Forbids every index file in in all sub folders under folder other than `types` / `pages` */
100+
'**/src/!(types|pages)*/**/index.ts*',
101+
/* Forbids every index file in in folders other than `types` / `pages` */
102+
'**/src/!(types|pages)*/index.ts*',
103+
/* Forbids to access index.ts in all folders in `pages` but not in subfolder `api` */
104+
'**/src/pages/!(api)*/**/index.ts*',
105+
],
106+
},
107+
],
108+
'import/no-cycle': 'off',
109+
'no-console': 'warn', // For debugging ease
110+
'no-underscore-dangle': 'off',
111+
'prettier/prettier': 'error',
112+
'simple-import-sort/exports': 'error',
113+
'simple-import-sort/imports': [
114+
'error',
115+
{
116+
groups: [['^@?w', '^(?!src)'], ['^(src)/'], ['((.|..)/)?']],
117+
},
118+
],
119+
'no-restricted-imports': [
120+
'error',
121+
{
122+
patterns: [
123+
{
124+
group: ['src/types/*', '!src/types/generated'],
125+
message: 'Please use src/types instead',
126+
},
127+
],
128+
},
129+
],
130+
},
131+
};

.github/CODEOWNERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
* @goodpickle
2+
* @Zonos/Frontend
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
yarn.lock
2+
lib

.github/actions/auto-assign/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
This action automatically adds assignees/reviewers to PRs. It will add the author, and a frontend engineer if the author is not a frontend engineer. The list of frontend engineers it chooses from is defined in `index.ts`.
2+
3+
Once changes are made to the source (`index.ts`) then run `yarn build` and added the built files.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
name: "PR auto assign"
2+
description: "Zonos specific auto-labeling action"
3+
author: "Zonos"
4+
runs:
5+
using: "node16"
6+
main: "index.js"

.github/actions/auto-assign/index.js

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"private": true,
3+
"name": "auto-assign",
4+
"version": "0",
5+
"exports": "./index.js",
6+
"files": [
7+
"src"
8+
],
9+
"scripts": {
10+
"pack": "ncc -m -o . build lib/index.js",
11+
"build": "tsc && yarn run pack"
12+
},
13+
"devDependencies": {
14+
"@octokit/webhooks-types": "6.9.0",
15+
"@types/node": "^18.11.0",
16+
"@vercel/ncc": "0.34.0",
17+
"typescript": "^4.9.5"
18+
},
19+
"dependencies": {
20+
"@actions/core": "^1.10.0",
21+
"@actions/github": "^5.1.1"
22+
}
23+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import * as github from '@actions/github';
2+
import * as core from '@actions/core';
3+
import { PullRequestEvent } from '@octokit/webhooks-types';
4+
5+
const engineerPool = ['evad1n', 'ckgardner', 'goodpickle', 'Thienhuynh95'];
6+
7+
async function run() {
8+
try {
9+
const { payload, issue } = github.context;
10+
const { pull_request } = payload as PullRequestEvent;
11+
12+
if (!pull_request) {
13+
throw new Error('No PR found');
14+
}
15+
16+
const author = pull_request.user.login;
17+
18+
const { owner, repo, number: issue_number } = issue;
19+
20+
if (!process.env.GITHUB_TOKEN) {
21+
throw new Error('No github token');
22+
}
23+
24+
const client = github.getOctokit(process.env.GITHUB_TOKEN).rest;
25+
console.log('Trying to add reviewers', JSON.stringify(engineerPool));
26+
const reviewerResult = await client.pulls.requestReviewers({
27+
owner,
28+
pull_number: issue_number,
29+
repo,
30+
/** Request all engineers that were not the author */
31+
reviewers: engineerPool.filter(engineer => engineer !== author),
32+
});
33+
core.debug('Reviewer response: ' + JSON.stringify(reviewerResult));
34+
35+
console.log('Trying to add assignees: ', JSON.stringify([author]));
36+
37+
const result = await client.issues.addAssignees({
38+
owner,
39+
repo,
40+
issue_number,
41+
assignees: [author],
42+
});
43+
44+
core.debug('Response: ' + JSON.stringify(result));
45+
} catch (error: any) {
46+
core.setFailed(error.message);
47+
}
48+
}
49+
50+
run();
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"compilerOptions": {
3+
"target": "esnext",
4+
"module": "commonjs",
5+
"outDir": "./lib",
6+
"rootDir": "./src",
7+
"strict": true,
8+
"noImplicitAny": true,
9+
"esModuleInterop": true,
10+
"typeRoots": ["./node_modules/@types"],
11+
},
12+
"exclude": ["node_modules", "../../../node_modules"],
13+
}

.github/pull_request_template.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
## Issue
2+
<!-- Example:
3+
Error when importing the sdk
4+
-->
5+
6+
## Description
7+
<!-- Explain what this Pull Request should do -->
8+
<!-- Example:
9+
This PR fixes a bug in our elastic search order query.
10+
-->
11+
This PR

.github/workflows/assign.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: "Auto Assign"
2+
3+
on:
4+
pull_request:
5+
types: [opened]
6+
7+
jobs:
8+
auto-assign:
9+
name: Auto add assignees/reviewers
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v3
13+
- uses: ./.github/actions/auto-assign
14+
env:
15+
GITHUB_TOKEN: ${{ github.token }}

.github/workflows/auto-release.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Auto Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
jobs:
9+
auto-release:
10+
name: "Auto Release"
11+
runs-on: "ubuntu-latest"
12+
13+
steps:
14+
- uses: "marvinpinto/[email protected]"
15+
with:
16+
repo_token: "${{ secrets.GITHUB_TOKEN }}"
17+
prerelease: false

.github/workflows/ci.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: CI
2+
3+
on: push
4+
5+
jobs:
6+
Build:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v3
10+
- uses: actions/setup-node@v3
11+
with:
12+
node-version: 18
13+
cache: "yarn"
14+
- run: yarn install --frozen-lockfile
15+
- run: yarn build
16+
17+
Lint:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v3
21+
- uses: actions/setup-node@v3
22+
with:
23+
node-version: 18
24+
cache: yarn
25+
- run: yarn install --frozen-lockfile
26+
- run: yarn lint
27+
28+
TSC:
29+
name: Check types
30+
runs-on: ubuntu-latest
31+
steps:
32+
- uses: actions/checkout@v3
33+
- uses: actions/setup-node@v3
34+
with:
35+
node-version: 18
36+
cache: yarn
37+
- run: yarn install --frozen-lockfile
38+
- run: yarn codegen && yarn tsc
39+
env:
40+
ZONOS_AUTH_GRAPH_URL: ${{ secrets.ZONOS_AUTH_GRAPH_URL }}
41+
ZONOS_CUSTOMER_GRAPH_URL: ${{ secrets.ZONOS_CUSTOMER_GRAPH_URL }}
42+
43+
Test:
44+
runs-on: ubuntu-latest
45+
steps:
46+
- uses: actions/checkout@v3
47+
- uses: actions/setup-node@v3
48+
with:
49+
node-version: 18
50+
cache: yarn
51+
- run: yarn install --frozen-lockfile
52+
- run: yarn codegen && yarn test:prod
53+
env:
54+
ZONOS_AUTH_GRAPH_URL: ${{ secrets.ZONOS_AUTH_GRAPH_URL }}
55+
ZONOS_CUSTOMER_GRAPH_URL: ${{ secrets.ZONOS_CUSTOMER_GRAPH_URL }}

.github/workflows/release-package.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Node.js Package
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
publish-gpr:
10+
needs: build
11+
runs-on: ubuntu-latest
12+
permissions:
13+
packages: write
14+
contents: read
15+
steps:
16+
- uses: actions/checkout@v3
17+
- uses: actions/setup-node@v3
18+
with:
19+
node-version: 18
20+
registry-url: https://npm.pkg.github.com/
21+
cache: "yarn"
22+
- run: yarn install --frozen-lockfile
23+
- run: yarn build
24+
- run: cd dist && npm publish
25+
env:
26+
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}

.npmignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
*.map
2+
__tests__
3+
*.tsbuildinfo

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@zonos:registry=https://npm.pkg.github.com

0 commit comments

Comments
 (0)