Skip to content

Commit

Permalink
Merge pull request #3 from Arylo/release/1.1.2
Browse files Browse the repository at this point in the history
Release to 1.1.2
  • Loading branch information
Arylo authored Oct 24, 2017
2 parents f1a0325 + 8490680 commit ea1385a
Show file tree
Hide file tree
Showing 10 changed files with 116 additions and 33 deletions.
20 changes: 20 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# 1.1.2

## Add

- A Example for Custom Config Module in Typescript Project
- Changelog File

## Update

- Update `.d.ts` File, it is more standardized.

## Remove

- Eslint Check

# 1.1.1

## Update

- Update `.d.ts` File
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ Create public configuration for the project
## Installation
```bash
npm install --save y-config
npm install --save-dev y-config
```

## Load Module
Expand Down
44 changes: 44 additions & 0 deletions dts.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
export interface AnyObject {
[prop: string]: any
}

export class Config<T extends AnyObject> {
/**
* Get Debug Status
*/
public getDebug(): boolean;
/**
* Set Debug Status
* @param bool status
*/
public setDebug(bool: boolean): boolean;

public on(event: string, cb: any): void;
public once(event: string, cb: any): void;

/**
* Display Stored Data
*/
public getConfig(): T;
/**
* Store Data
* @param obj data
*/
public setConfig(obj: T): boolean;

public clearConfigCwd(): boolean;
public getConfigCwd(): boolean;
public setConfigCwd(cwd: string): boolean;

public clearConfigPath(): boolean;
public clearCustomConfigPath(): boolean;
public getConfigPath(): string;
public getCustomConfigPath(): string;
public setConfigPath(filepath: string): boolean;
public setCustomConfigPath(filepath: string): boolean;

public clear(): boolean;
public reload(): boolean;

[prop: string]: any;
}
4 changes: 4 additions & 0 deletions examples/custom_config_module/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import config = require('config');

const test = config.test;
const bar = config.bar;
15 changes: 15 additions & 0 deletions examples/custom_config_module/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "custom_config_module",
"version": "1.0.0",
"description": "",
"main": "index.js",
"keywords": [
"y-config",
"example"
],
"author": "AryloYeung <[email protected]>",
"license": "MIT",
"dependencies": {
"y-config": "file:../../"
}
}
6 changes: 6 additions & 0 deletions examples/custom_config_module/test.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { AnyObject } from 'y-config/dts';

export interface NewObject extends AnyObject {
test: string;
bar: 'foo';
}
7 changes: 7 additions & 0 deletions examples/custom_config_module/test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { NewObject } from './test.d';
import config = require('y-config');

config.test = 'test';
config.bar = 'foo';

export = <NewObject>config.getConfig();
13 changes: 13 additions & 0 deletions examples/custom_config_module/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"strict": true,
/* Add Start */
"baseUrl": ".",
"paths": {
"config": ["test.ts"]
}
/* Add End */
}
}
30 changes: 3 additions & 27 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,7 @@
interface AnyObject {
[prop: string]: any
}
import { Config, AnyObject } from './dts.d';

declare module "y-config" {
function getDebug(): boolean;
function setDebug(bool: boolean): boolean;

function on(event: string, cb: any): void;
function once(event: string, cb: any): void;

function getConfig(): AnyObject;
function setConfig(obj: any): boolean;

function clearConfigCwd(): boolean;
function getConfigCwd(): boolean;
function setConfigCwd(cwd: string): boolean;

function clearConfigPath(): boolean;
function clearCustomConfigPath(): boolean;
function getConfigPath(): string;
function getCustomConfigPath(): string;
function setConfigPath(filepath: string): boolean;
function setCustomConfigPath(filepath: string): boolean;

function clear(): boolean;
function reload(): boolean;
export = new Config();
}

declare let config: "y-config";
export = config;
export = new Config();
9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
{
"name": "y-config",
"version": "1.1.1",
"version": "1.1.2",
"description": "Create public configuration for the project",
"main": "index.js",
"types": "index.d.ts",
"scripts": {
"pretest": "npm run lint",
"test": "mocha -r should -R list",
"lint": "eslint ./",
"prepublish": "npm run test"
},
"repository": {
Expand All @@ -22,7 +20,9 @@
"node-config",
"env",
"environment",
"common"
"common",
"typescript",
"coffeescript"
],
"author": "AryloYeung <[email protected]>",
"license": "MIT",
Expand All @@ -36,7 +36,6 @@
"lodash": "^4.17.4"
},
"devDependencies": {
"eslint": "^3.18.0",
"mocha": "^3.2.0",
"should": "^11.2.1"
}
Expand Down

0 comments on commit ea1385a

Please sign in to comment.