chai-latte
Advanced tools
Comparing version 0.1.2 to 0.2.0
@@ -5,6 +5,7 @@ #! /usr/bin/env node | ||
const tslib_1 = require("tslib"); | ||
const tsnode_1 = require("./codegen/tsnode"); | ||
const commander_1 = require("commander"); | ||
const chokidar_1 = tslib_1.__importDefault(require("chokidar")); | ||
const fs_1 = tslib_1.__importDefault(require("fs")); | ||
const path_1 = tslib_1.__importDefault(require("path")); | ||
const compileUsingTsNode_1 = require("./codegen/actions/compileUsingTsNode"); | ||
const getPkgInfo = () => { | ||
@@ -19,17 +20,23 @@ const pkgjsonPath = path_1.default.resolve(__dirname, '..', 'package.json'); | ||
.version(pkgInfo.version) | ||
.option('-i --input <path>', 'input file path') | ||
.option('-i --output <filename>', 'desired generated file name'); | ||
.option('-i --input <path>', 'Input file path that should be typed') | ||
.option('-o --output <filename>', 'Desired generated file name') | ||
.option('-w --watch', 'Watch for changes and re-generate typed file'); | ||
commander_1.program.parse(); | ||
const options = commander_1.program.opts(); | ||
const entryFile = options.input || './index'; | ||
const outputFileName = options.output ? `${options.output}.ts` : 'generated.ts'; | ||
// We need to run the script with ts-node | ||
// to be able to import entry ts file | ||
(0, tsnode_1.tsnode) ` | ||
import { generateTypedApiFromPath } from 'chai-latte'; | ||
generateTypedApiFromPath({ | ||
input: '${entryFile}', | ||
output: '${outputFileName}' | ||
}); | ||
`; | ||
const input = options.input || './index'; | ||
const output = options.output ? `${options.output}.ts` : 'generated.ts'; | ||
const runCompilation = () => { | ||
console.log('Start compiling...'); | ||
(0, compileUsingTsNode_1.compileUsingTsNode)({ | ||
input, | ||
output, | ||
}); | ||
console.log('Done!'); | ||
}; | ||
runCompilation(); | ||
if (options.watch) { | ||
const watchPath = path_1.default.resolve(process.cwd(), input + '.ts'); | ||
chokidar_1.default.watch(watchPath) | ||
.on('change', runCompilation); | ||
} | ||
//# sourceMappingURL=cli.js.map |
@@ -17,3 +17,3 @@ import { compile, expression } from 'chai-latte'; | ||
return withNarration(() => { | ||
// return new State(stateName, { initial: true }); | ||
// return new State(stateName, { initial: true }); aaaaa | ||
}); | ||
@@ -30,2 +30,10 @@ } | ||
), | ||
expression( | ||
({ it }) => it.can.be(String), | ||
(stateName: string) => { | ||
return withNarration(() => { | ||
// return new State(stateName); | ||
}); | ||
} | ||
), | ||
); |
{ | ||
"version": "0.1.2", | ||
"version": "0.2.0", | ||
"name": "chai-latte", | ||
@@ -38,2 +38,3 @@ "description": "Build expressive & readable fluent interface libraries.", | ||
"dependencies": { | ||
"chokidar": "^3.5.3", | ||
"commander": "^9.4.0", | ||
@@ -40,0 +41,0 @@ "tslib": "^2.4.0" |
#! /usr/bin/env node | ||
import { tsnode } from './codegen/tsnode'; | ||
import { program } from 'commander'; | ||
import chokidar from 'chokidar'; | ||
import fs from 'fs'; | ||
import path from 'path'; | ||
import { compileUsingTsNode } from './codegen/actions/compileUsingTsNode'; | ||
@@ -19,4 +20,5 @@ const getPkgInfo = () => { | ||
.version(pkgInfo.version) | ||
.option('-i --input <path>', 'input file path') | ||
.option('-i --output <filename>', 'desired generated file name'); | ||
.option('-i --input <path>', 'Input file path that should be typed') | ||
.option('-o --output <filename>', 'Desired generated file name') | ||
.option('-w --watch', 'Watch for changes and re-generate typed file'); | ||
@@ -26,13 +28,23 @@ program.parse(); | ||
const options = program.opts(); | ||
const entryFile = options.input || './index'; | ||
const outputFileName = options.output ? `${options.output}.ts` : 'generated.ts'; | ||
// We need to run the script with ts-node | ||
// to be able to import entry ts file | ||
tsnode` | ||
import { generateTypedApiFromPath } from 'chai-latte'; | ||
generateTypedApiFromPath({ | ||
input: '${entryFile}', | ||
output: '${outputFileName}' | ||
const input = options.input || './index'; | ||
const output = options.output ? `${options.output}.ts` : 'generated.ts'; | ||
const runCompilation = () => { | ||
console.log('Start compiling...'); | ||
compileUsingTsNode({ | ||
input, | ||
output, | ||
}); | ||
`; | ||
console.log('Done!'); | ||
} | ||
runCompilation(); | ||
if (options.watch) { | ||
const watchPath = path.resolve(process.cwd(), input + '.ts'); | ||
chokidar.watch(watchPath) | ||
.on('change', runCompilation); | ||
} |
Sorry, the diff of this file is not supported yet
213164
94
2764
3
2
+ Addedchokidar@^3.5.3
+ Addedanymatch@3.1.3(transitive)
+ Addedbinary-extensions@2.3.0(transitive)
+ Addedbraces@3.0.3(transitive)
+ Addedchokidar@3.6.0(transitive)
+ Addedfill-range@7.1.1(transitive)
+ Addedfsevents@2.3.3(transitive)
+ Addedglob-parent@5.1.2(transitive)
+ Addedis-binary-path@2.1.0(transitive)
+ Addedis-extglob@2.1.1(transitive)
+ Addedis-glob@4.0.3(transitive)
+ Addedis-number@7.0.0(transitive)
+ Addednormalize-path@3.0.0(transitive)
+ Addedpicomatch@2.3.1(transitive)
+ Addedreaddirp@3.6.0(transitive)
+ Addedto-regex-range@5.0.1(transitive)