Comparing version 0.8.0 to 0.9.0
@@ -9,3 +9,2 @@ "use strict"; | ||
var getConfig_1 = __importDefault(require("./getConfig")); | ||
var getInputs_1 = __importDefault(require("./getInputs")); | ||
var writeRouteFile_1 = __importDefault(require("./writeRouteFile")); | ||
@@ -22,8 +21,9 @@ var watchInputDir_1 = __importDefault(require("./watchInputDir")); | ||
return build_1.CommandToBuild.getFactory(config, { | ||
read: getInputs_1.default, | ||
write: writeRouteFile_1.default, | ||
watch: watchInputDir_1.default, | ||
remove: function (filePath, callback) { | ||
fs_1.default.unlink(filePath, callback); | ||
} | ||
read: function (_a) { | ||
var input = _a.input; | ||
return (Array.isArray(input) ? input : [input]); | ||
}, | ||
remove: function (filePath, callback) { return fs_1.default.unlink(filePath, callback); } | ||
}); | ||
@@ -30,0 +30,0 @@ }; |
@@ -18,3 +18,3 @@ import { Config } from '../getConfig'; | ||
export interface BuildIO { | ||
read(input?: string | string[]): string[]; | ||
read(config: Config): string[]; | ||
write(template: Template): void; | ||
@@ -21,0 +21,0 @@ remove(filePath: string, callback: () => void): void; |
@@ -23,3 +23,3 @@ "use strict"; | ||
var _this = this; | ||
this.io.read(this.config.input).forEach(function (input) { | ||
this.io.read(this.config).forEach(function (input) { | ||
_this.command.run(input, _this.io); | ||
@@ -36,3 +36,3 @@ }); | ||
var template = buildTemplate_1.default(input); | ||
io.write(template); | ||
io.remove(template.filePath, function () { return io.write(template); }); | ||
}; | ||
@@ -49,7 +49,5 @@ return Build; | ||
Watch.prototype.run = function (input, io) { | ||
var _this = this; | ||
this.build.run(input, io); | ||
io.watch(input, function () { | ||
var result = buildTemplate_1.default(input); | ||
io.remove(result.filePath, function () { return io.write(result); }); | ||
}); | ||
io.watch(input, function () { return _this.build.run(input, io); }); | ||
}; | ||
@@ -56,0 +54,0 @@ return Watch; |
export declare type Config = { | ||
input?: string | string[]; | ||
input: string | string[]; | ||
}; | ||
export declare const apiFileRegExp: RegExp; | ||
export declare const defaultConfig: { | ||
input: string; | ||
}; | ||
declare const _default: (rcFilePath?: string) => Config; | ||
declare const _default: (configPath?: string) => Config; | ||
export default _default; | ||
//# sourceMappingURL=getConfig.d.ts.map |
@@ -7,10 +7,10 @@ "use strict"; | ||
var fs_1 = __importDefault(require("fs")); | ||
exports.apiFileRegExp = /\/\$[^/]+\.(js|ts)$/; | ||
exports.defaultConfig = { | ||
input: 'apis' | ||
}; | ||
exports.default = (function (rcFilePath) { | ||
if (rcFilePath === void 0) { rcFilePath = '.aspidarc'; } | ||
return fs_1.default.existsSync(rcFilePath) ? JSON.parse(fs_1.default.readFileSync(rcFilePath, 'utf8')) : {}; | ||
var path_1 = __importDefault(require("path")); | ||
var defaultConfig = { input: 'apis' }; | ||
exports.default = (function (configPath) { | ||
if (configPath === void 0) { configPath = 'aspida.config.js'; } | ||
return (fs_1.default.existsSync(configPath) && | ||
require(path_1.default.join(process.cwd(), configPath))[require('../package.json').name]) || | ||
defaultConfig; | ||
}); | ||
//# sourceMappingURL=getConfig.js.map |
@@ -1,11 +0,8 @@ | ||
import 'url-search-params-polyfill'; | ||
export declare type BasicHeaders = { | ||
export declare type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'HEAD' | 'PATCH' | 'OPTIONS'; | ||
declare type BasicHeaders = { | ||
[key: string]: string; | ||
}; | ||
export declare type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'HEAD' | 'PATCH'; | ||
export interface AspidaRequest<T = any> { | ||
query?: { | ||
[key: string]: any; | ||
}; | ||
headers?: BasicHeaders; | ||
query?: any; | ||
headers?: any; | ||
body?: T; | ||
@@ -20,3 +17,3 @@ } | ||
export interface AspidaClient { | ||
fetch: <T, U extends BasicHeaders = BasicHeaders>(url: string, method: HttpMethod, request?: AspidaRequest) => { | ||
fetch: <T, U = BasicHeaders>(url: string, method: HttpMethod, request?: AspidaRequest) => { | ||
send(): Promise<AspidaResponse<null, U>>; | ||
@@ -30,3 +27,3 @@ json(): Promise<AspidaResponse<T, U>>; | ||
} | ||
export declare function headersToObject<T extends BasicHeaders>(headers: Headers): T; | ||
export declare function headersToObject<T>(headers: Headers): T; | ||
export declare function dataToURLString(data: { | ||
@@ -33,0 +30,0 @@ [key: string]: any; |
@@ -34,3 +34,2 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
require("url-search-params-polyfill"); | ||
function headersToObject(headers) { | ||
@@ -37,0 +36,0 @@ return __spread(headers.entries()).reduce(function (prev, _a) { |
@@ -7,6 +7,5 @@ "use strict"; | ||
var chokidar_1 = __importDefault(require("chokidar")); | ||
var getConfig_1 = require("./getConfig"); | ||
exports.default = (function (input, callback) { | ||
chokidar_1.default.watch(input, { ignoreInitial: true, ignored: getConfig_1.apiFileRegExp }).on('all', callback); | ||
chokidar_1.default.watch(input, { ignoreInitial: true, ignored: /\/\$[^/]+\.(js|ts)$/ }).on('all', callback); | ||
}); | ||
//# sourceMappingURL=watchInputDir.js.map |
{ | ||
"name": "aspida", | ||
"version": "0.8.0", | ||
"version": "0.9.0", | ||
"description": "Type safe HTTP client wrapper for the browser and node.js", | ||
@@ -26,11 +26,7 @@ "author": "m-mitsuhide <m.mitsuhide@amatelus.com>", | ||
], | ||
"scripts": { | ||
"build": "rimraf dist && tsc --project tsconfig.build.json" | ||
}, | ||
"dependencies": { | ||
"chokidar": "^3.3.1", | ||
"minimist": "^1.2.0", | ||
"ts-morph": "^6.0.2", | ||
"url-search-params-polyfill": "^7.0.1" | ||
"ts-morph": "^6.0.2" | ||
} | ||
} |
@@ -177,7 +177,7 @@ <p align="right"> | ||
`.aspidarc` | ||
`aspida.config.js` | ||
```json | ||
{ | ||
"input": "src" | ||
```javascript | ||
module.exports = { | ||
aspida: { input: 'src' } | ||
} | ||
@@ -188,5 +188,5 @@ ``` | ||
```json | ||
{ | ||
"input": ["api1", "api2"] | ||
```javascript | ||
module.exports = { | ||
aspida: { input: ['api1', 'api2'] } | ||
} | ||
@@ -314,17 +314,2 @@ ``` | ||
<!-- | ||
## Contribution | ||
### Build | ||
```bash | ||
npm install | ||
npm run build | ||
node ./bin/index.js --build | ||
``` | ||
if you want to watch file changes and rebuild automatically, | ||
you can use `--watch` instead of `--build` | ||
--> | ||
## License | ||
@@ -331,0 +316,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3
52640
56
543
341
6
- Removedurl-search-params-polyfill@^7.0.1
- Removedurl-search-params-polyfill@7.0.1(transitive)