Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jean9696 committed Jun 19, 2020
0 parents commit 26def3d
Show file tree
Hide file tree
Showing 10 changed files with 378 additions and 0 deletions.
174 changes: 174 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
# --------------------------------------------------- #
# https://github.com/habx/devops-template-circleci #
# ----------- DO NOT EDIT BELOW THIS LINE ----------- #
# --------------------------------------------------- #
version: 2.1

# --- Anchor alias ---- #
# - Docker configuration - #
alias:
# https://circleci.com/docs/2.0/circleci-images/#nodejs
- &docker_node12_configuration
docker:
- image: circleci/node:12.0.0
user: root
- &docker_buildpack_deps_configuration
docker:
- image: circleci/buildpack-deps:stretch
user: root
- &docker_buildpack_deps_python_configuration
docker:
- image: circleci/python
user: root
# - Jobs filters - #
- &filters_ignore_tags
tags:
ignore: /.*/
- &filters_ignore_branches
branches:
ignore: /.*/
- &filters_allow_tags
tags:
only: /^v.*/
- &filters_allow_branch_dev
branches:
only:
- dev
# - Step - #
- &preconfig
run:
name: Preconfigure environment ~/.npmrc
command: |
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
# - Node modules - #
- &install_node_modules_with_cache
node/with-cache:
dir: node_modules
cache-version: dev{{ .Environment.CACHE_VERSION }}
steps:
- run:
name: Install node module
command: npm install
- &install_node_modules_with_cache_production
node/with-cache:
dir: node_modules
cache-version: prod{{ .Environment.CACHE_VERSION }}
steps:
- run:
name: Install node module production
command: npm install --production
- &fetch_node_modules_with_cache_production
node/with-cache:
dir: node_modules
cache-version: prod{{ .Environment.CACHE_VERSION }}
steps:
- run: echo
jobs:
build:
<<: *docker_node12_configuration
steps:
- checkout
- *preconfig
- *install_node_modules_with_cache_production
- *install_node_modules_with_cache
- run: export NODE_ENV=production; npm run build
- persist_to_workspace:
root: ~/project
paths:
- dist

storybook-build:
<<: *docker_node12_configuration
steps:
- checkout
- *preconfig
- *install_node_modules_with_cache
- attach_workspace:
at: ~/project
- *preconfig
- *install_node_modules_with_cache
- run: npm run storybook:build

lint:
<<: *docker_node12_configuration
steps:
- checkout
- *preconfig
- *install_node_modules_with_cache
- run: npm run lint

tests:
<<: *docker_node12_configuration
steps:
- checkout
- *preconfig
- *install_node_modules_with_cache
- run: npm run test
tests-puppeteer:
docker:
- image: jean9696/drone-puppeteer
parallelism: 1
steps:
- checkout
- attach_workspace:
at: ~/project
- *preconfig
- *install_node_modules_with_cache
- run:
name: Puppeteer test
command: |
apt-get -yq update
apt-get -y install nginx
sed -i 's/root.*/root \/root\/project\/build-test\/;/' /etc/nginx/sites-enabled/default
nginx -c /etc/nginx/nginx.conf
chmod -R a+rx /root/
npm run test
environment:
HABX_ROLE: admin
LOCAL_URL: http://localhost

npm-publish:
<<: *docker_node12_configuration
steps:
- checkout
- attach_workspace:
at: ~/project
- *preconfig
- *install_node_modules_with_cache
- run: NPM_TOKEN=${NPM_TOKEN_RW} npm publish

storybook-publish:
<<: *docker_node12_configuration
steps:
- checkout
- attach_workspace:
at: ~/project
- *preconfig
- *install_node_modules_with_cache
- run: npm run storybook:deploy

orbs:
node: circleci/[email protected]
# --- END --- #
# --------------------------------------------------- #
# -------------- DEFINE YOUR WORKFLOW --------------- #
# --------------------------------------------------- #
workflows:
build:
jobs:
- build:
context: default_env_vars
filters:
<<: *filters_allow_tags
- lint:
context: default_env_vars
filters:
<<: *filters_allow_tags
- npm-publish:
context: default_env_vars
requires:
- build
- lint
filters:
<<: *filters_allow_tags
<<: *filters_ignore_branches
34 changes: 34 additions & 0 deletions .dependabot/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
version: 1
update_configs:
- package_manager: "javascript"
directory: "/"
update_schedule: "live"
version_requirement_updates: "auto"
# https://dependabot.com/docs/config-file/#automerged_updates
automerged_updates:
- match:
dependency_type: "development"
update_type: "all"
- match:
dependency_type: "production"
update_type: "semver:patch"
- match:
dependency_type: "production"
update_type: "in_range"
- match:
dependency_name: "lodash"
- match:
dependency_name: "@types/*"
- match:
dependency_name: "@habx/*"
update_type: "in_range"
- match:
dependency_name: "@habx/*"
update_type: "semver:minor"
- match:
dependency_name: "lint-staged"
- match:
dependency_name: "typescript"
- match:
dependency_name: "@sentry/*"
update_type: "semver:minor"
3 changes: 3 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": ["@habx/client/typescript"]
}
16 changes: 16 additions & 0 deletions .github/auto-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Configuration for probot-auto-merge - https://github.com/bobvanderlinden/probot-auto-merge

updateBranch: true
deleteBranchAfterMerge: true
maxRequestedChanges:
NONE: 0
blockingLabels:
- blocked
blockingTitleRegex: '\bWIP\b'
rules:
- minApprovals:
CONTRIBUTOR: 1
- requiredLabels:
- habx-automerge
# APP-11930: Automatically merging pre-1.0.0 dependencies
- requiredBodyRegex: 'because this dependency is pre-1.0.0'
43 changes: 43 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Environment Configuration
.env

# Build output folders
lib/
dist/

# Logs
logs
*.log
.cache
.rpt2_cache

# Coverage directory used by tools like istanbul
coverage

# node-waf configuration
.lock-wscript

# Dependency directory
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git-
node_modules

# Debug log from npm
npm-debug.log

# IntelliJ IDE ignore
.idea

# Visual Studio Code
.vscode
.history

# flow-typed Lib Defs
flow-typed/

# Flow Coverage Report
flow-coverage/

# OSX Files
.DS_Store

.storybook-static/
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Template for typescript library creation

- Output both ESM and CommonJS formats
- Tree shaking
- TypeScript support
20 changes: 20 additions & 0 deletions bili.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { Config } from 'bili'

const config: Config = {
plugins: {
babel: false,
typescript2: {
useTsconfigDeclarationDir: true,
tsconfigOverride: {
declaration: false,
},
},
},
input: 'src/index.ts',
output: {
fileName: '[name].[format].js',
format: 'cjs',
},
}

export default config
54 changes: 54 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"name": "@habx/tslib-template",
"version": "0.0.1",
"description": "Typescript library template",
"main": "./dist/index.cjs.js",
"module": "./dist/esm/index.js",
"types": "./dist/typings/index.d.ts",
"sideEffects": false,
"scripts": {
"clean": "rimraf ./dist",
"build": "npm run clean && npm run build:esm && npm run build:cjs",
"build:esm": "tsc",
"build:cjs": "bili",
"build:watch": "npm run clean && tsc --watch",
"generate:snapshots": "node ./scripts/generateSnapshot.js",
"lint": "eslint \"src/**\"",
"test": "jest",
"test:coverage": "jest --coverage",
"type:coverage": "tscov"
},
"files": [
"dist"
],
"repository": {
"type": "git",
"url": "git+https://github.com/habx/lib-template.git"
},
"author": "HABX Front End Team",
"license": "ISC",
"bugs": {
"url": "https://github.com/habx/lib-template/issues"
},
"homepage": "https://github.com/habx/lib-template#readme",
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"*.{ts,tsx}": [
"eslint --fix"
]
},
"dependencies": {},
"devDependencies": {
"@habx/eslint-config-client": "^3.0.1",
"bili": "^5.0.2",
"husky": "^4.2.3",
"lint-staged": "^10.0.1",
"rimraf": "^3.0.0",
"rollup-plugin-typescript2": "^0.27.0",
"typescript": "^3.8.3"
}
}
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default {}
28 changes: 28 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"compilerOptions": {
"jsx": "react",
"outDir": "./dist/esm",
"declarationDir": "./dist/typings",
"baseUrl": "typings",
"target": "ES5",
"module": "ES2015",
"moduleResolution": "Node",
"lib": ["ESNext", "DOM"],
"typeRoots": ["./node_modules/@types", "./typings"],
"strict": true,
"removeComments": true,
"sourceMap": true,
"declaration": true,
"declarationMap": true,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"skipLibCheck": true,
"resolveJsonModule": true
},
"include": ["./src/**/*"],
"exclude": ["./src/**/*.spec.ts"],
"typedocOptions": {
"mode": "file",
"out": "docs"
}
}

0 comments on commit 26def3d

Please sign in to comment.