Skip to content

Commit

Permalink
chore: setup repo structure and dev workflow (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinpagtakhan authored Jan 24, 2022
1 parent 24543c7 commit d96f3b0
Show file tree
Hide file tree
Showing 25 changed files with 7,405 additions and 1 deletion.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**/*.js
36 changes: 36 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
module.exports = {
root: true,
env: {
es6: true,
'jest/globals': true,
},
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 2018,
project: "packages/*/tsconfig.json",
sourceType: 'module',
tsconfigRootDir: __dirname,
},
plugins: [
'@typescript-eslint',
'jest',
],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'plugin:jest/recommended',
'prettier',
],
rules: {
'@typescript-eslint/member-delimiter-style': 0,
'@typescript-eslint/no-explicit-any': 0,
'@typescript-eslint/semi': 0,
'@typescript-eslint/space-before-function-paren': 0,
'comma-dangle': 0,
'new-cap': 0,
'eol-last': [2, "always"],
'no-multiple-empty-lines': [2, { max: 1, maxEOF: 0 }],
},
};
50 changes: 50 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Continuous Integration

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
build:
name: Build
strategy:
fail-fast: false
matrix:
node-version: [12.x, 14.x, 16.x]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}

steps:
- name: Check out git repository
uses: actions/checkout@v2

- name: Cache dependencies
uses: actions/cache@v2
with:
path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}

- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

- name: Install project dependencies
run: |
yarn install --frozen-lockfile
- name: Build all packages
run: |
yarn build
- name: Test all packages
run: |
yarn test
- name: Lint all packages
run: |
yarn lint
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules/

dist/
esm
*.tsbuildinfo
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn commitlint --edit $1
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn lint:staged
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.md
6 changes: 6 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"printWidth": 120,
"proseWrap": "always",
"singleQuote": true,
"trailingComma": "all"
}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Amplitude-TypeScript
3 changes: 3 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
extends: ['@commitlint/config-conventional']
};
7 changes: 7 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
preset: 'ts-jest',
transform: {
'^.+\\.ts$': 'ts-jest',
},
moduleFileExtensions: ['ts', 'js', 'json'],
};
8 changes: 8 additions & 0 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"packages": [
"packages/*"
],
"version": "independent",
"npmClient": "yarn",
"useWorkspaces": true
}
36 changes: 35 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,37 @@
{
"private": true
"private": true,
"workspaces": [
"packages/*"
],
"scripts": {
"build": "lerna run build --stream",
"fix": "lerna run fix --stream",
"lint": "lerna run lint --stream",
"lint:staged": "lint-staged",
"postinstall": "husky install",
"test": "lerna run test --stream"
},
"devDependencies": {
"@commitlint/cli": "^16.1.0",
"@commitlint/config-conventional": "^16.0.0",
"@types/jest": "^27.4.0",
"@typescript-eslint/eslint-plugin": "^5.10.0",
"@typescript-eslint/parser": "^5.10.0",
"eslint": "^8.7.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-jest": "^25.7.0",
"husky": "^7.0.4",
"jest": "^27.4.7",
"lerna": "^4.0.0",
"lint-staged": "^12.2.2",
"prettier": "^2.5.1",
"ts-jest": "^27.1.3",
"typescript": "^4.5.5"
},
"lint-staged": {
"*.ts": [
"eslint --fix",
"prettier --write"
]
}
}
1 change: 1 addition & 0 deletions packages/core/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# @amplitude/core
9 changes: 9 additions & 0 deletions packages/core/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const baseConfig = require('../../jest.config.js');
const package = require('./package');

module.exports = {
...baseConfig,
displayName: package.name,
rootDir: '.',
testEnvironment: 'node',
};
34 changes: 34 additions & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "@amplitude/core",
"version": "0.0.0",
"description": "",
"author": "Amplitude Inc",
"homepage": "https://github.com/amplitude/Amplitude-TypeScript",
"license": "MIT",
"main": "dist/index.js",
"module": "esm/index.js",
"types": "dist/index.d.ts",
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "git+https://github.com/amplitude/Amplitude-TypeScript.git"
},
"scripts": {
"build": "yarn build:es5 & yarn build:esm",
"build:es5": "tsc -p ./tsconfig.es5.json",
"build:esm": "tsc -p ./tsconfig.esm.json",
"fix": "yarn fix:eslint & yarn fix:prettier",
"fix:eslint": "eslint '{src,test}/**/*.ts' --fix",
"fix:prettier": "prettier --write \"{src,test}/**/*.ts\"",
"lint": "yarn lint:eslint & yarn lint:prettier",
"lint:eslint": "eslint '{src,test}/**/*.ts'",
"lint:prettier": "prettier --check \"{src,test}/**/*.ts\"",
"test": "jest",
"typecheck": "tsc -p ./tsconfig.json"
},
"bugs": {
"url": "https://github.com/amplitude/Amplitude-TypeScript/issues"
}
}
3 changes: 3 additions & 0 deletions packages/core/src/AmplitudeCore.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class AmplitudeCore {}

export default AmplitudeCore;
3 changes: 3 additions & 0 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import AmplitudeCore from './AmplitudeCore';

export { AmplitudeCore };
10 changes: 10 additions & 0 deletions packages/core/test/AmplitudeCore.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import AmplitudeCore from '../src/AmplitudeCore';

describe('index', () => {
describe('AmplitudeCore', () => {
test('should instantiate AmplitudeCore', () => {
const instance = new AmplitudeCore();
expect(instance).toBeDefined();
});
});
});
10 changes: 10 additions & 0 deletions packages/core/test/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { AmplitudeCore } from '../src/index';

describe('index', () => {
describe('AmplitudeCore', () => {
test('should export AmplitudeCore', () => {
const instance = new AmplitudeCore();
expect(instance).toBeDefined();
});
});
});
10 changes: 10 additions & 0 deletions packages/core/tsconfig.es5.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "./tsconfig.json",
"include": ["src/**/*"],
"compilerOptions": {
"module": "commonjs",
"noEmit": false,
"outDir": "dist",
"rootDir": "./src"
}
}
10 changes: 10 additions & 0 deletions packages/core/tsconfig.esm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "./tsconfig.json",
"include": ["src/**/*"],
"compilerOptions": {
"module": "es6",
"noEmit": false,
"outDir": "esm",
"rootDir": "./src"
}
}
9 changes: 9 additions & 0 deletions packages/core/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../../tsconfig.json",
"include": ["src/**/*", "test/**/*"],
"compilerOptions": {
"baseUrl": ".",
"noEmit": true,
"rootDir": "."
}
}
28 changes: 28 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"compilerOptions": {
"alwaysStrict": false,
"declaration": true,
"declarationMap": true,
"downlevelIteration": true,
"inlineSources": true,
"importHelpers": true,
"lib": ["es6"],
"module": "commonjs",
"moduleResolution": "node",
"noEmitHelpers": true,
"noFallthroughCasesInSwitch": true,
"noImplicitAny": true,
"noImplicitReturns": true,
"noImplicitUseStrict": true,
"noImplicitThis": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"pretty": true,
"sourceMap": true,
"resolveJsonModule": true,
"strict": true,
"strictBindCallApply": true,
"target": "es5",
"types": ["jest"],
}
}
Loading

0 comments on commit d96f3b0

Please sign in to comment.