diff --git a/.gitignore b/.gitignore index 619e811..f7363ae 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ node_modules coverage .local-pack *.tgz -workdir \ No newline at end of file +workdir +.vscode diff --git a/package-lock.json b/package-lock.json index 02094bd..d51ddd4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,6 +12,7 @@ "@babel/core": "^7.14.2", "@babel/preset-env": "^7.14.2", "@eslint/js": "^9.5.0", + "@faker-js/faker": "^8.4.1", "@rollup/plugin-babel": "^6.0.4", "@rollup/plugin-commonjs": "^26.0.1", "@rollup/plugin-node-resolve": "^15.2.3", @@ -21,7 +22,6 @@ "core-js": "^3.13.0", "coveralls-next": "^4.2.1", "eslint": "^9.5.0", - "faker": "^5.5.3", "globals": "^15.6.0", "jsdoc": "^4.0.3", "mocha": "^10.4.0", @@ -2013,6 +2013,22 @@ "node": "^18.18.0 || ^20.9.0 || >=21.1.0" } }, + "node_modules/@faker-js/faker": { + "version": "8.4.1", + "resolved": "https://registry.npmjs.org/@faker-js/faker/-/faker-8.4.1.tgz", + "integrity": "sha512-XQ3cU+Q8Uqmrbf2e0cIC/QN43sTBSC8KF12u29Mb47tWrt2hAgBXSgpZMj4Ao8Uk0iJcU99QsOCaIL8934obCg==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/fakerjs" + } + ], + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0", + "npm": ">=6.14.13" + } + }, "node_modules/@humanwhocodes/module-importer": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz", @@ -3897,12 +3913,6 @@ "node": ">=0.10.0" } }, - "node_modules/faker": { - "version": "5.5.3", - "resolved": "https://registry.npmjs.org/faker/-/faker-5.5.3.tgz", - "integrity": "sha512-wLTv2a28wjUyWkbnX7u/ABZBkUkIF2fCd73V6P2oFqEGEktDfzWx4UxrSqtPRw0xPRAcjeAOIiJWqZm3pP4u3g==", - "dev": true - }, "node_modules/fast-deep-equal": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", @@ -8757,6 +8767,12 @@ "integrity": "sha512-BsWiH1yFGjXXS2yvrf5LyuoSIIbPrGUWob917o+BTKuZ7qJdxX8aJLRxs1fS9n6r7vESrq1OUqb68dANcFXuQQ==", "dev": true }, + "@faker-js/faker": { + "version": "8.4.1", + "resolved": "https://registry.npmjs.org/@faker-js/faker/-/faker-8.4.1.tgz", + "integrity": "sha512-XQ3cU+Q8Uqmrbf2e0cIC/QN43sTBSC8KF12u29Mb47tWrt2hAgBXSgpZMj4Ao8Uk0iJcU99QsOCaIL8934obCg==", + "dev": true + }, "@humanwhocodes/module-importer": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz", @@ -10121,12 +10137,6 @@ "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", "dev": true }, - "faker": { - "version": "5.5.3", - "resolved": "https://registry.npmjs.org/faker/-/faker-5.5.3.tgz", - "integrity": "sha512-wLTv2a28wjUyWkbnX7u/ABZBkUkIF2fCd73V6P2oFqEGEktDfzWx4UxrSqtPRw0xPRAcjeAOIiJWqZm3pP4u3g==", - "dev": true - }, "fast-deep-equal": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", diff --git a/package.json b/package.json index f06e4ae..ac276cd 100644 --- a/package.json +++ b/package.json @@ -42,6 +42,7 @@ "@babel/core": "^7.14.2", "@babel/preset-env": "^7.14.2", "@eslint/js": "^9.5.0", + "@faker-js/faker": "^8.4.1", "@rollup/plugin-babel": "^6.0.4", "@rollup/plugin-commonjs": "^26.0.1", "@rollup/plugin-node-resolve": "^15.2.3", @@ -51,7 +52,6 @@ "core-js": "^3.13.0", "coveralls-next": "^4.2.1", "eslint": "^9.5.0", - "faker": "^5.5.3", "globals": "^15.6.0", "jsdoc": "^4.0.3", "mocha": "^10.4.0", diff --git a/src/ODataMockGenerator.js b/src/ODataMockGenerator.js index 47c3573..345b9b8 100644 --- a/src/ODataMockGenerator.js +++ b/src/ODataMockGenerator.js @@ -25,7 +25,7 @@ //! (c) Copyright 2009-2021 SAP SE or an SAP affiliate company. //! Licensed under the Apache License, Version 2.0 - see https://github.com/SAP/openui5/blob/master/LICENSE.txt. -import faker from "faker"; +import { faker } from "@faker-js/faker"; import { parseXML } from "./xmlParser.js"; import { DataGenerator } from "./DataGenerator.js"; import * as metadataExtract from "./metadataExtract.js"; @@ -432,7 +432,7 @@ export class ODataMockGenerator { // Mustache template? try { if (fakerCall.indexOf("{{") !== -1) { - generatedValue = faker.fake(fakerCall); + generatedValue = faker.helpers.fake(fakerCall); } else { const fakerCallParts = fakerCall.split("."); generatedValue = faker[fakerCallParts[0]][fakerCallParts[1]].call(); diff --git a/test/withFaker.js b/test/withFaker.js index 9b73dbc..d451cb3 100644 --- a/test/withFaker.js +++ b/test/withFaker.js @@ -51,7 +51,7 @@ describe("ODataMockGenerator - generating with faker", () => { rules: { faker: { Supplier: { - Name: "{{system.semver}} --- {{datatype.number}}", + Name: "{{system.semver}} --- {{number.int}}", }, }, },