Skip to content

Commit

Permalink
Version 1.0.0 (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
siyul-park authored Aug 30, 2020
1 parent ee70e1b commit 87d3603
Show file tree
Hide file tree
Showing 37 changed files with 970 additions and 22 deletions.
8 changes: 5 additions & 3 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,20 @@
"jest": true
},
"extends": [
"airbnb-typescript/base",
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended",
"prettier/@typescript-eslint",
"airbnb-base"
"prettier/@typescript-eslint"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 12,
"sourceType": "module",
"project": [
"tsconfig.json"
"tsconfig.json",
"package/conev-core/tsconfig.json",
"package/conev-json-source/tsconfig.json"
]
},
"plugins": [
Expand Down
38 changes: 38 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Test CI

on:
push:
branches:
- 'master'
- 'develop'
- 'release'
pull_request:
branches:
- 'master'
- 'develop'
- 'release'

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [12.x]

steps:
- name: Checkout source code
uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: npm install
- name: Lint
run: npm run lint
- name: Build
run: npm run all:build:production
- name: Test
run: npm run test
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# Design System
# conev sync
17 changes: 11 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "design-system",
"name": "conev-sync",
"version": "1.0.0",
"description": "",
"main": "dist/index.js",
Expand All @@ -8,18 +8,19 @@
"build:production": "cross-env NODE_ENV=production npm run build",
"build": "gulp",
"neon": "neon",
"lint": "eslint --fix . --resolve-plugins-relative-to .",
"lint": "eslint . --resolve-plugins-relative-to .",
"lint:fix": "eslint --fix . --resolve-plugins-relative-to .",
"lint:staged": "lint-staged",
"test": "jest",
"package:init": "script/init-package.sh package",
"package:sync": "script/sync-package.sh package",
"package:snpync": "script/sync-package.sh package",
"package:neon:init": "script/init-neon-package.sh package",
"tsc:init": "tsc --init",
"eslint": "eslint",
"all:install": "script/run-command-all-package.sh install",
"all:build": "script/run-command-all-package.sh run build",
"all:build:production": "script/run-command-all-package.sh run build:production",
"prepublish": "npm run all:build:production && npm run test"
"prepublish": "npm run all:build:production"
},
"repository": {
"type": "git",
Expand All @@ -38,7 +39,7 @@
}
},
"lint-staged": {
"src/*.{js,ts}": [
"*.{js,ts}": [
"eslint --fix"
]
},
Expand Down Expand Up @@ -67,7 +68,7 @@
"@typescript-eslint/parser": "^3.10.1",
"cross-env": "^7.0.2",
"eslint": "^7.7.0",
"eslint-config-airbnb-base": "^14.2.0",
"eslint-config-airbnb-typescript": "^9.0.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-prettier": "^3.1.4",
Expand All @@ -80,5 +81,9 @@
"prettier": "^2.1.1",
"ts-jest": "^26.3.0",
"typescript": "^4.0.2"
},
"dependencies": {
"conev-core": "file:package/conev-core",
"conev-json-source": "file:package/conev-json-source"
}
}
4 changes: 4 additions & 0 deletions package/conev-core/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
script
node_modules
dist
gulpfile.js
5 changes: 5 additions & 0 deletions package/conev-core/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"extends": [
"../../.eslintrc.json"
]
}
112 changes: 112 additions & 0 deletions package/conev-core/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
# Logs
old/logs
*.log
*.log.*
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc tests coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules
jspm_packages/

# TypeScript v1 declaration files
typings/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

# Next.js build output
.next

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and *not* Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

package-lock.json
/storage/
mongodb-binaries/
/profiling/
/.vscode/
.idea
4 changes: 4 additions & 0 deletions package/conev-core/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
src
script
template
.github
19 changes: 19 additions & 0 deletions package/conev-core/gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const gulp = require('gulp');
const ts = require('gulp-typescript');

function getTsconfig(env) {
if (env != null) {
return `tsconfig.${env.toLowerCase()}.json`;
}

return 'tsconfig.json';
}

const tsProject = ts.createProject(getTsconfig(process.env.NODE_ENV));

const outDir = 'dist'

gulp.task('default', () => tsProject.src()
.pipe(tsProject())
.pipe(gulp.dest(outDir))
);
46 changes: 46 additions & 0 deletions package/conev-core/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"name": "conev-core",
"version": "1.0.0",
"description": "",
"main": "dist/index.js",
"scripts": {
"test": "jest",
"run": "node dist/index.js",
"build": "gulp",
"build:production": "cross-env NODE_ENV=production npm run build",
"install": "npm run build:production"
},
"author": "",
"license": "ISC",
"devDependencies": {
"@types/jest": "^26.0.10",
"@types/node": "^14.6.2",
"cross-env": "^7.0.2",
"gulp": "^4.0.2",
"gulp-typescript": "^6.0.0-alpha.1",
"jest": "^26.4.2",
"ts-jest": "^26.3.0",
"typescript": "^4.0.2"
},
"jest": {
"transform": {
"^.+\\.ts$": "ts-jest"
},
"testRegex": "\\.spec\\.ts$",
"moduleFileExtensions": [
"ts",
"js"
],
"modulePathIgnorePatterns": [
"dist"
],
"globals": {
"ts-jest": {
"diagnostics": true
}
}
},
"dependencies": {
"deepmerge": "^4.2.2"
}
}
41 changes: 41 additions & 0 deletions package/conev-core/src/config/config-builder.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import ConfigBuilder from './config-builder';
import SourceMock from '../source/source.mock';

describe('config-builder', () => {
const source1 = new SourceMock(
new Map<string, Record<string, unknown>>([
['default', { source: '1', port: 3000, db: { type: 'postgres' } }],
['develop', { env: 'develop', port: 3001 }],
])
);

const source2 = new SourceMock(
new Map<string, Record<string, unknown>>([
[
'default',
{
source: '2',
port: 3000,
db: { port: 7070, username: 'test', type: 'mysql' },
},
],
['production', { env: 'production', port: 3002 }],
])
);

test('build', () => {
const config = new ConfigBuilder()
.addSource(source1, source2)
.addEnv('default', 'develop')
.build();

expect(config.get()).toEqual({
source: '2',
env: 'develop',
port: 3001,
db: { port: 7070, username: 'test', type: 'mysql' },
});
expect(config.get('source')).toEqual('2');
expect(config.get('db.port')).toEqual(7070);
});
});
33 changes: 33 additions & 0 deletions package/conev-core/src/config/config-builder.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { Options } from 'deepmerge';
import Config from './config';
import Source from '../source/source';

export default class ConfigBuilder {
private readonly sources: Source[] = [];

private readonly envs: string[] = [];

private options?: Options;

addSource(...sources: Source[]): ConfigBuilder {
this.sources.push(...sources);

return this;
}

addEnv(...envs: string[]): ConfigBuilder {
this.envs.push(...envs);

return this;
}

setOptions(options?: Options): ConfigBuilder {
this.options = options;

return this;
}

build(): Config {
return new Config(this.sources, this.envs, this.options);
}
}
Loading

0 comments on commit 87d3603

Please sign in to comment.