diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..b27b57e --- /dev/null +++ b/.circleci/config.yml @@ -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/node@1.0.1 +# --- 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 diff --git a/.dependabot/config.yml b/.dependabot/config.yml new file mode 100644 index 0000000..1d78630 --- /dev/null +++ b/.dependabot/config.yml @@ -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" diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..ef98238 --- /dev/null +++ b/.eslintrc @@ -0,0 +1,3 @@ +{ + "extends": ["@habx/client/typescript"] +} diff --git a/.github/auto-merge.yml b/.github/auto-merge.yml new file mode 100644 index 0000000..13d9be0 --- /dev/null +++ b/.github/auto-merge.yml @@ -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' diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..52054cf --- /dev/null +++ b/.gitignore @@ -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/ diff --git a/README.md b/README.md new file mode 100644 index 0000000..3ff000f --- /dev/null +++ b/README.md @@ -0,0 +1,5 @@ +# Template for typescript library creation + +- Output both ESM and CommonJS formats +- Tree shaking +- TypeScript support diff --git a/bili.config.ts b/bili.config.ts new file mode 100644 index 0000000..cb3a857 --- /dev/null +++ b/bili.config.ts @@ -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 diff --git a/package.json b/package.json new file mode 100644 index 0000000..6a2b96c --- /dev/null +++ b/package.json @@ -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" + } +} diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..b1c6ea4 --- /dev/null +++ b/src/index.ts @@ -0,0 +1 @@ +export default {} diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..6bb9dd1 --- /dev/null +++ b/tsconfig.json @@ -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" + } +}