Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31,256 changes: 19,209 additions & 12,047 deletions package-lock.json

Large diffs are not rendered by default.

79 changes: 38 additions & 41 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,54 +10,51 @@
"intermock": "build/src/cli/index.js"
},
"dependencies": {
"command-line-args": "5.0.2",
"command-line-usage": "5.0.5",
"faker": "4.1.0",
"command-line-args": "5.2.1",
"command-line-usage": "6.1.3",
"fs-readfile-promise": "3.0.1",
"tslib": "1.10.0",
"typescript": "^3.7.5"
"tslib": "2.5.0",
"@faker-js/faker": "^7.6.0",
"typescript": "^4.9.5"
},
"main": "./build/index.js",
"types": "./build/index.d.ts",
"devDependencies": {
"@types/chai": "4.1.3",
"@types/command-line-args": "5.0.0",
"@types/command-line-usage": "5.0.1",
"@types/faker": "4.1.2",
"@types/fs-readfile-promise": "3.0.0",
"@types/mocha": "5.2.0",
"@types/node": "^8.10.45",
"chai": "4.1.2",
"clang-format": "1.4.0",
"clean-webpack-plugin": "^1.0.1",
"closure-webpack-plugin": "^1.2.0",
"copy-webpack-plugin": "^4.6.0",
"css-loader": "^1.0.1",
"husky": "^4.3.6",
"mini-css-extract-plugin": "^0.4.5",
"mocha": "5.2.0",
"mocha-multi-reporters": "1.1.7",
"@types/chai": "4.3.4",
"@types/command-line-args": "5.2.0",
"@types/command-line-usage": "5.0.2",
"@types/faker": "6.6.8",
"@types/fs-readfile-promise": "3.0.1",
"@types/mocha": "10.0.1",
"@types/node": "^18.11.18",
"chai": "4.3.7",
"clang-format": "1.8.0",
"clean-webpack-plugin": "^4.0.0",
"copy-webpack-plugin": "^11.0.0",
"css-loader": "^6.7.3",
"husky": "^8.0.3",
"mini-css-extract-plugin": "^2.7.2",
"mocha": "10.2.0",
"mocha-multi-reporters": "1.5.1",
"mocha-notifier-reporter": "0.1.2",
"monaco-editor": "^0.15.6",
"node-sass": "^4.12.0",
"nyc": "12.0.2",
"rimraf": "^2.6.3",
"sass-loader": "^7.1.0",
"source-map-support": "^0.5.12",
"style-loader": "^0.23.1",
"ts-jest": "^22.4.6",
"ts-loader": "^5.3.3",
"ts-node": "6.0.5",
"tslint": "~5.9.1",
"tslint-microsoft-contrib": "~5.0.3",
"tsutils": "~2.26.2",
"uglifyjs-webpack-plugin": "^2.1.2",
"monaco-editor": "^0.34.1",
"node-sass": "^8.0.0",
"nyc": "15.1.0",
"rimraf": "^4.1.2",
"sass-loader": "^13.2.0",
"source-map-support": "^0.5.21",
"style-loader": "^3.3.1",
"ts-jest": "^29.0.5",
"ts-loader": "^9.4.2",
"ts-node": "10.9.1",
"tslint": "~5.20.1",
"tsutils": "~3.21.0",
"watch-cli": "0.2.3",
"webpack": "^4.29.6",
"webpack-cli": "^3.3.0",
"webpack-dev-server": "^3.3.1",
"webpack-merge": "^4.2.1",
"webpack-notifier": "^1.7.0"
"webpack": "^5.75.0",
"webpack-cli": "^5.0.1",
"webpack-dev-server": "^4.11.1",
"webpack-merge": "^5.8.0",
"webpack-notifier": "^1.15.0"
},
"scripts": {
"clean": "rimraf coverage build tmp",
Expand Down
73 changes: 39 additions & 34 deletions src/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,60 +15,59 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import commandLineArgs from 'command-line-args';
import commandLineUsage from 'command-line-usage';

import {mock as IntermockTS, OutputType} from '../lang/ts/intermock';
import {readFiles} from '../lib/read-files';
import {setImportExportSpecifier} from '../lib/resolve-file-imports';
import commandLineArgs from "command-line-args";
import commandLineUsage from "command-line-usage";

import { mock as IntermockTS, OutputType } from "../lang/ts/intermock";
import { readFiles } from "../lib/read-files";
import { setImportExportSpecifier } from "../lib/resolve-file-imports";

const optionDefinitions = [
{
name: 'files',
alias: 'f',
name: "files",
alias: "f",
type: String,
multiple: true,
defaultOption: true
defaultOption: true,
},
{name: 'interfaces', alias: 'i', type: String, multiple: true},
{name: 'help', alias: 'h', type: Boolean},
{name: 'fixed', alias: 'x', type: Boolean},
{name: 'outputFormat', alias: 'o', type: String},
{name: 'resolveFileImports', alias: 'r', type: Boolean},
{ name: "interfaces", alias: "i", type: String, multiple: true },
{ name: "help", alias: "h", type: Boolean },
{ name: "fixed", alias: "x", type: Boolean },
{ name: "outputFormat", alias: "o", type: String },
{ name: "resolveFileImports", alias: "r", type: Boolean },
];

const instructions = [
{
content: 'Intermock',
content: "Intermock",
raw: true,
},
{
header: '',
content: 'Generates fake data from TypeScript interfaces via Faker',
header: "",
content: "Generates fake data from TypeScript interfaces via Faker",
},
{
header: 'Options',
header: "Options",
optionList: [
{
name: 'interfaces',
name: "interfaces",
typeLabel: 'example: --interfaces "Person" "User"',
description: 'Optional list of interfaces to mock',
description: "Optional list of interfaces to mock",
},
{
name: 'files',
typeLabel: 'example: web/apps/some-directory/interfaces1.ts',
description: 'Interface files to generate fake data from',
name: "files",
typeLabel: "example: web/apps/some-directory/interfaces1.ts",
description: "Interface files to generate fake data from",
},
{
name: 'outputFormat',
typeLabel: 'example: json',
description: 'Format to use for output. Can be string, json or object',
name: "outputFormat",
typeLabel: "example: json",
description: "Format to use for output. Can be string, json or object",
},
{
name: 'help',
description: 'Print this usage guide.',
}
name: "help",
description: "Print this usage guide.",
},
],
},
];
Expand Down Expand Up @@ -107,17 +106,23 @@ function main() {
const isFixedMode = options.fixed;
const interfaces = options.interfaces;
const output = options.outputFormat;
const importsResolver =
options.resolveFileImports ? setImportExportSpecifier : undefined;
const importsResolver = options.resolveFileImports
? setImportExportSpecifier
: undefined;

return readFiles(options.files).then((files) => {
try {
const result = IntermockTS(
{files, interfaces, isFixedMode, output, importsResolver});
const result = IntermockTS({
files,
interfaces,
isFixedMode,
output,
importsResolver,
});

console.log(result);
} catch (err) {
console.log(err.message);
console.log(err);
}
});
}
Expand Down
Loading