Skip to content

Commit

Permalink
fix: change bin filename
Browse files Browse the repository at this point in the history
  • Loading branch information
Chacaponquin committed Nov 6, 2024
1 parent e9a5446 commit cf97551
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 12 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
"exports": "./lib/index.js",
"bin": {
"chaca": "./lib/bin/index.js"
"chaca": "./lib/bin/chaca.js"
},
"files": [
"lib/**/*",
Expand Down
18 changes: 12 additions & 6 deletions src/Chaca.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ export class Chaca {
/**
* @param input The object with the keys and type of each field
* @example
* {
* chaca.schema({
* id: () => modules.id.uuid(),
* image: () => modules.image.film(),
* name: () => modules.person.firstName()
* }
* })
*/
schema<K = any>(input: SchemaInput): Schema<K> {
const newSchema = new Schema<K>(input, this.utils, this.datatypeModule);
Expand All @@ -65,13 +65,16 @@ export class Chaca {
* @param values Array of the secuential values
* @param config.loop Boolean indicating whether the values should be generated cyclically. Default `false`
* @example
* // the first generated object will have the number with value 1
* // the second generated object will have the number with value 2
* // the third generated object will have the number with value 3
*
* chaca.schema({
* number: chaca.sequential([1, 2, 3])
* })
*
* // array result
* [
* { number: 1 },
* { number: 2 },
* { number: 3 }
* ]
*/
sequential<K = any>(values: K[], config?: SequentialFieldConfig) {
return new SequentialField(values, config);
Expand Down Expand Up @@ -101,6 +104,9 @@ export class Chaca {
/**
* Enum field
* @param values Array of posible values
*
* @example
* chaca.enum(["category1", "category2", "category3"])
*/
enum<R = any>(values: ReadonlyArray<R>) {
return new EnumField<R>(values);
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions test/cli/cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import { describe, expect, it } from "vitest";
describe("CLI", () => {
it("missing --filename. should fail", () => {
const result = exec(
"node ./lib/bin/index.js json --count 50 --output data/cli/dataset --config test/cli/dataset/wrong-dataset.js",
"node ./lib/bin/chaca.js json --count 50 --output data/cli/dataset --config test/cli/dataset/wrong-dataset.js",
);

expect(result.code).toBe(1);
});

it("missing --config. should fail", () => {
const result = exec(
"node ./lib/bin/index.js json --filename dataset-test --count 50 --output data/cli/dataset",
"node ./lib/bin/chaca.js json --filename dataset-test --count 50 --output data/cli/dataset",
);

expect(result.code).toBe(1);
Expand Down
4 changes: 2 additions & 2 deletions test/cli/dataset/dataset.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import { exec } from "shelljs";
describe("Dataset CLI", () => {
it("export dataset example. should return an empty string", () => {
const result = exec(
"node ./lib/bin/index.js json --count 50 --filename dataset --output data/cli/dataset --config test/cli/dataset/dataset.js",
"node ./lib/bin/chaca.js json --count 50 --filename dataset --output data/cli/dataset --config test/cli/dataset/dataset.js",
);

expect(result.code).toBe(0);
});

it("dataset with empty schema name. should throw an error", () => {
const result = exec(
"node ./lib/bin/index.js json --count 50 --filename data-test --output data/cli/dataset --config test/cli/dataset/wrong-dataset.js",
"node ./lib/bin/chaca.js json --count 50 --filename data-test --output data/cli/dataset --config test/cli/dataset/wrong-dataset.js",
);

expect(result.code).toBe(1);
Expand Down
2 changes: 1 addition & 1 deletion test/cli/schema/schema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { describe, expect, it } from "vitest";
describe("Schema CLI", () => {
it("export 50 objects from schema", () => {
const result = exec(
"node ./lib/bin/index.js json --count 50 --filename schema-array --output data/cli/schema --config test/cli/schema/schema.js",
"node ./lib/bin/chaca.js json --count 50 --filename schema-array --output data/cli/schema --config test/cli/schema/schema.js",
);

expect(result.code).toBe(0);
Expand Down

0 comments on commit cf97551

Please sign in to comment.