mirror of
https://github.com/typeorm/typeorm.git
synced 2025-12-08 21:26:23 +00:00
refactor: use node:fs/promises (#11206)
* refactor: use fs promises * refactor: remove del, update rimraf
This commit is contained in:
parent
30f801f9f0
commit
71addb2ef4
12
gulpfile.ts
12
gulpfile.ts
@ -1,13 +1,13 @@
|
||||
import { Gulpclass, Task, SequenceTask, MergedTask } from "gulpclass";
|
||||
|
||||
import fs from "fs";
|
||||
import fs from "fs/promises";
|
||||
import gulp from "gulp";
|
||||
import del from "del";
|
||||
import shell from "gulp-shell";
|
||||
import replace from "gulp-replace";
|
||||
import rename from "gulp-rename";
|
||||
import sourcemaps from "gulp-sourcemaps";
|
||||
import ts from "gulp-typescript";
|
||||
import { rimraf } from "rimraf";
|
||||
|
||||
@Gulpclass()
|
||||
export class Gulpfile {
|
||||
@ -21,7 +21,7 @@ export class Gulpfile {
|
||||
*/
|
||||
@Task()
|
||||
async clean() {
|
||||
return del(["./build/**"]);
|
||||
return rimraf(["./build/**"]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -86,7 +86,7 @@ export class Gulpfile {
|
||||
|
||||
@Task()
|
||||
async browserClearPackageDirectory() {
|
||||
return del([
|
||||
return rimraf([
|
||||
"./build/browser/**"
|
||||
]);
|
||||
}
|
||||
@ -174,7 +174,7 @@ export class Gulpfile {
|
||||
`export {\n ${cjsKeys.join(",\n ")}\n};\n` +
|
||||
'export default TypeORM;\n';
|
||||
|
||||
fs.writeFileSync(`${buildDir}/index.mjs`, indexMjsContent, "utf8");
|
||||
await fs.writeFile(`${buildDir}/index.mjs`, indexMjsContent, "utf8");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -193,7 +193,7 @@ export class Gulpfile {
|
||||
*/
|
||||
@Task()
|
||||
async packageClearPackageDirectory() {
|
||||
return del([
|
||||
return rimraf([
|
||||
"build/package/src/**"
|
||||
]);
|
||||
}
|
||||
|
||||
228
package-lock.json
generated
228
package-lock.json
generated
@ -18,7 +18,6 @@
|
||||
"debug": "^4.3.4",
|
||||
"dotenv": "^16.0.3",
|
||||
"glob": "^10.4.5",
|
||||
"mkdirp": "^2.1.3",
|
||||
"sha.js": "^2.4.11",
|
||||
"tslib": "^2.5.0",
|
||||
"uuid": "^9.0.0",
|
||||
@ -32,13 +31,11 @@
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^9.17.0",
|
||||
"@tsconfig/node16": "^16.1.1",
|
||||
"@types/app-root-path": "^1.2.4",
|
||||
"@types/chai": "^4.3.4",
|
||||
"@types/chai-as-promised": "^7.1.5",
|
||||
"@types/debug": "^4.1.7",
|
||||
"@types/gulp-rename": "^2.0.6",
|
||||
"@types/gulp-sourcemaps": "^0.0.38",
|
||||
"@types/mkdirp": "^1.0.2",
|
||||
"@types/mocha": "^10.0.1",
|
||||
"@types/node": "^18.13.0",
|
||||
"@types/sha.js": "^2.4.0",
|
||||
@ -52,7 +49,6 @@
|
||||
"class-transformer": "^0.5.1",
|
||||
"conventional-changelog-angular": "^5.0.13",
|
||||
"conventional-changelog-cli": "^2.2.2",
|
||||
"del": "6.1.1",
|
||||
"eslint": "^9.17.0",
|
||||
"globals": "^15.14.0",
|
||||
"gulp": "^4.0.2",
|
||||
@ -75,7 +71,7 @@
|
||||
"prettier": "^2.8.8",
|
||||
"redis": "^4.6.4",
|
||||
"remap-istanbul": "^0.13.0",
|
||||
"rimraf": "^4.1.2",
|
||||
"rimraf": "^5.0.10",
|
||||
"sinon": "^15.0.1",
|
||||
"sinon-chai": "^3.7.0",
|
||||
"source-map-support": "^0.5.21",
|
||||
@ -1325,12 +1321,6 @@
|
||||
"integrity": "sha512-+pio93ejHN4nINX4pXqfnR/fPLRtJBaT4ORaa5RH0Oc1zoYmo2B2koG+M328CQhHKn1Wj6FcOxCDFXAot9NhvA==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@types/app-root-path": {
|
||||
"version": "1.2.8",
|
||||
"resolved": "https://registry.npmjs.org/@types/app-root-path/-/app-root-path-1.2.8.tgz",
|
||||
"integrity": "sha512-l12miuN6JXAi3yuADZNhRKbyN7IIyaUP9hFVZ/BbHhWYpBkHLbOaX2WkQoXGJyAgMcP9iZ0S9+tz/FN40VrwWQ==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@types/chai": {
|
||||
"version": "4.3.11",
|
||||
"resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.3.11.tgz",
|
||||
@ -1577,15 +1567,6 @@
|
||||
"integrity": "sha512-hov8bUuiLiyFPGyFPE1lwWhmzYbirOXQNNo40+y3zow8aFVTeyn3VWL0VFFfdNddA8S4Vf0Tc062rzyNr7Paag==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@types/mkdirp": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/@types/mkdirp/-/mkdirp-1.0.2.tgz",
|
||||
"integrity": "sha512-o0K1tSO0Dx5X6xlU5F1D6625FawhC3dU3iqr25lluNv/+/QIVH8RLNEiVokgIZo+mz+87w/3Mkg/VvQS+J51fQ==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/mocha": {
|
||||
"version": "10.0.6",
|
||||
"resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-10.0.6.tgz",
|
||||
@ -2017,6 +1998,7 @@
|
||||
"resolved": "https://registry.npmjs.org/aggregate-error/-/aggregate-error-3.1.0.tgz",
|
||||
"integrity": "sha512-4I7Td01quW/RpocfNayFdFVk1qSuoh0E7JrbRJ16nH01HhKFQ88INq9Sd+nd72zqRySlr9BmDA8xlEJ6vJMrYA==",
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"dependencies": {
|
||||
"clean-stack": "^2.0.0",
|
||||
"indent-string": "^4.0.0"
|
||||
@ -2492,15 +2474,6 @@
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/array-union": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz",
|
||||
"integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/array-unique": {
|
||||
"version": "0.3.2",
|
||||
"resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz",
|
||||
@ -3231,6 +3204,7 @@
|
||||
"resolved": "https://registry.npmjs.org/clean-stack/-/clean-stack-2.2.0.tgz",
|
||||
"integrity": "sha512-4diC9HaTE+KRAMWhDhrGOECgWZxoevMc5TlkObMqNSsVU62PYzXZ/SMTjzyGAFF1YusgxGcSWTEXBhp0CPwQ1A==",
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
}
|
||||
@ -4090,63 +4064,6 @@
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/del": {
|
||||
"version": "6.1.1",
|
||||
"resolved": "https://registry.npmjs.org/del/-/del-6.1.1.tgz",
|
||||
"integrity": "sha512-ua8BhapfP0JUJKC/zV9yHHDW/rDoDxP4Zhn3AkA6/xT6gY7jYXJiaeyBZznYVujhZZET+UgcbZiQ7sN3WqcImg==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"globby": "^11.0.1",
|
||||
"graceful-fs": "^4.2.4",
|
||||
"is-glob": "^4.0.1",
|
||||
"is-path-cwd": "^2.2.0",
|
||||
"is-path-inside": "^3.0.2",
|
||||
"p-map": "^4.0.0",
|
||||
"rimraf": "^3.0.2",
|
||||
"slash": "^3.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/del/node_modules/glob": {
|
||||
"version": "7.2.3",
|
||||
"resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz",
|
||||
"integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"fs.realpath": "^1.0.0",
|
||||
"inflight": "^1.0.4",
|
||||
"inherits": "2",
|
||||
"minimatch": "^3.1.1",
|
||||
"once": "^1.3.0",
|
||||
"path-is-absolute": "^1.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "*"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/isaacs"
|
||||
}
|
||||
},
|
||||
"node_modules/del/node_modules/rimraf": {
|
||||
"version": "3.0.2",
|
||||
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz",
|
||||
"integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"glob": "^7.1.3"
|
||||
},
|
||||
"bin": {
|
||||
"rimraf": "bin.js"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/isaacs"
|
||||
}
|
||||
},
|
||||
"node_modules/delegates": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz",
|
||||
@ -4198,18 +4115,6 @@
|
||||
"node": ">=0.3.1"
|
||||
}
|
||||
},
|
||||
"node_modules/dir-glob": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz",
|
||||
"integrity": "sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"path-type": "^4.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/dot-prop": {
|
||||
"version": "5.3.0",
|
||||
"resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-5.3.0.tgz",
|
||||
@ -5977,26 +5882,6 @@
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/globby": {
|
||||
"version": "11.1.0",
|
||||
"resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz",
|
||||
"integrity": "sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"array-union": "^2.1.0",
|
||||
"dir-glob": "^3.0.1",
|
||||
"fast-glob": "^3.2.9",
|
||||
"ignore": "^5.2.0",
|
||||
"merge2": "^1.4.1",
|
||||
"slash": "^3.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/glogg": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/glogg/-/glogg-1.0.2.tgz",
|
||||
@ -7505,24 +7390,6 @@
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/is-path-cwd": {
|
||||
"version": "2.2.0",
|
||||
"resolved": "https://registry.npmjs.org/is-path-cwd/-/is-path-cwd-2.2.0.tgz",
|
||||
"integrity": "sha512-w942bTcih8fdJPJmQHFzkS76NEP8Kzzvmw92cXsazb8intwLqPibPPdXf4ANdKV3rYMuuQYGIWtvz9JilB3NFQ==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/is-path-inside": {
|
||||
"version": "3.0.3",
|
||||
"resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz",
|
||||
"integrity": "sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/is-plain-obj": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-1.1.0.tgz",
|
||||
@ -9303,20 +9170,6 @@
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/mkdirp": {
|
||||
"version": "2.1.6",
|
||||
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-2.1.6.tgz",
|
||||
"integrity": "sha512-+hEnITedc8LAtIP9u3HJDFIdcLV2vXP33sqLLIzkv1Db1zO/1OxbvYf0Y1OC/S/Qo5dxHXepofhmxL02PsKe+A==",
|
||||
"bin": {
|
||||
"mkdirp": "dist/cjs/src/bin.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/isaacs"
|
||||
}
|
||||
},
|
||||
"node_modules/mkdirp-classic": {
|
||||
"version": "0.5.3",
|
||||
"resolved": "https://registry.npmjs.org/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz",
|
||||
@ -10590,6 +10443,7 @@
|
||||
"resolved": "https://registry.npmjs.org/p-map/-/p-map-4.0.0.tgz",
|
||||
"integrity": "sha512-/bjOqmgETBYB5BoEeGVea8dmvHb2m9GLy1E9W43yeyfP6QQCZGFNa+XRceJEuDB6zqr+gKpIAmlLebMpykw/MQ==",
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"dependencies": {
|
||||
"aggregate-error": "^3.0.0"
|
||||
},
|
||||
@ -10799,15 +10653,6 @@
|
||||
"integrity": "sha512-D2S+3GLxWH+uhrNEcoh/fnmYeP8E8/zHl644d/jdA0g2uyXvy3sb0qxotE+ne0LtccHknQzWwZEzhak7oJ0COQ==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/path-type": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz",
|
||||
"integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/pathval": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.1.tgz",
|
||||
@ -12000,65 +11845,21 @@
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/rimraf": {
|
||||
"version": "4.4.1",
|
||||
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-4.4.1.tgz",
|
||||
"integrity": "sha512-Gk8NlF062+T9CqNGn6h4tls3k6T1+/nXdOcSZVikNVtlRdYpA7wRJJMoXmuvOnLW844rPjdQ7JgXCYM6PPC/og==",
|
||||
"version": "5.0.10",
|
||||
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-5.0.10.tgz",
|
||||
"integrity": "sha512-l0OE8wL34P4nJH/H2ffoaniAokM2qSmrtXHmlpvYr5AVVX8msAyW0l8NVJFDxlSK4u3Uh/f41cQheDVdnYijwQ==",
|
||||
"dev": true,
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"glob": "^9.2.0"
|
||||
"glob": "^10.3.7"
|
||||
},
|
||||
"bin": {
|
||||
"rimraf": "dist/cjs/src/bin.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14"
|
||||
"rimraf": "dist/esm/bin.mjs"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/isaacs"
|
||||
}
|
||||
},
|
||||
"node_modules/rimraf/node_modules/glob": {
|
||||
"version": "9.3.5",
|
||||
"resolved": "https://registry.npmjs.org/glob/-/glob-9.3.5.tgz",
|
||||
"integrity": "sha512-e1LleDykUz2Iu+MTYdkSsuWX8lvAjAcs0Xef0lNIu0S2wOAzuTxCJtcd9S3cijlwYF18EsU3rzb8jPVobxDh9Q==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"fs.realpath": "^1.0.0",
|
||||
"minimatch": "^8.0.2",
|
||||
"minipass": "^4.2.4",
|
||||
"path-scurry": "^1.6.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16 || 14 >=14.17"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/isaacs"
|
||||
}
|
||||
},
|
||||
"node_modules/rimraf/node_modules/minimatch": {
|
||||
"version": "8.0.4",
|
||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-8.0.4.tgz",
|
||||
"integrity": "sha512-W0Wvr9HyFXZRGIDgCicunpQ299OKXs9RgZfaukz4qAW/pJhcpUfupc9c+OObPOFueNy8VSrZgEmDtk6Kh4WzDA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"brace-expansion": "^2.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16 || 14 >=14.17"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/isaacs"
|
||||
}
|
||||
},
|
||||
"node_modules/rimraf/node_modules/minipass": {
|
||||
"version": "4.2.8",
|
||||
"resolved": "https://registry.npmjs.org/minipass/-/minipass-4.2.8.tgz",
|
||||
"integrity": "sha512-fNzuVyifolSLFL4NzpF+wEF4qrgqaaKX0haXPQEdQ7NKAN+WecoKMHV09YcuL/DHxrUsYQOK3MiuDf7Ip2OXfQ==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/run-parallel": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz",
|
||||
@ -12372,15 +12173,6 @@
|
||||
"sinon": ">=4.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/slash": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz",
|
||||
"integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/smart-buffer": {
|
||||
"version": "4.2.0",
|
||||
"resolved": "https://registry.npmjs.org/smart-buffer/-/smart-buffer-4.2.0.tgz",
|
||||
|
||||
@ -95,13 +95,11 @@
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^9.17.0",
|
||||
"@tsconfig/node16": "^16.1.1",
|
||||
"@types/app-root-path": "^1.2.4",
|
||||
"@types/chai": "^4.3.4",
|
||||
"@types/chai-as-promised": "^7.1.5",
|
||||
"@types/debug": "^4.1.7",
|
||||
"@types/gulp-rename": "^2.0.6",
|
||||
"@types/gulp-sourcemaps": "^0.0.38",
|
||||
"@types/mkdirp": "^1.0.2",
|
||||
"@types/mocha": "^10.0.1",
|
||||
"@types/node": "^18.13.0",
|
||||
"@types/sha.js": "^2.4.0",
|
||||
@ -115,7 +113,6 @@
|
||||
"class-transformer": "^0.5.1",
|
||||
"conventional-changelog-angular": "^5.0.13",
|
||||
"conventional-changelog-cli": "^2.2.2",
|
||||
"del": "6.1.1",
|
||||
"eslint": "^9.17.0",
|
||||
"globals": "^15.14.0",
|
||||
"gulp": "^4.0.2",
|
||||
@ -138,7 +135,7 @@
|
||||
"prettier": "^2.8.8",
|
||||
"redis": "^4.6.4",
|
||||
"remap-istanbul": "^0.13.0",
|
||||
"rimraf": "^4.1.2",
|
||||
"rimraf": "^5.0.10",
|
||||
"sinon": "^15.0.1",
|
||||
"sinon-chai": "^3.7.0",
|
||||
"source-map-support": "^0.5.21",
|
||||
@ -232,7 +229,6 @@
|
||||
"debug": "^4.3.4",
|
||||
"dotenv": "^16.0.3",
|
||||
"glob": "^10.4.5",
|
||||
"mkdirp": "^2.1.3",
|
||||
"sha.js": "^2.4.11",
|
||||
"tslib": "^2.5.0",
|
||||
"uuid": "^9.0.0",
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
import * as fs from "fs"
|
||||
import * as path from "path"
|
||||
import mkdirp from "mkdirp"
|
||||
import fs from "fs/promises"
|
||||
import path from "path"
|
||||
import { TypeORMError } from "../error"
|
||||
import { DataSource } from "../data-source"
|
||||
import { InstanceChecker } from "../util/InstanceChecker"
|
||||
@ -15,7 +14,7 @@ export class CommandUtils {
|
||||
): Promise<DataSource> {
|
||||
let dataSourceFileExports
|
||||
try {
|
||||
;[dataSourceFileExports] = await importOrRequireFile(
|
||||
[dataSourceFileExports] = await importOrRequireFile(
|
||||
dataSourceFilePath,
|
||||
)
|
||||
} catch (err) {
|
||||
@ -66,8 +65,8 @@ export class CommandUtils {
|
||||
/**
|
||||
* Creates directories recursively.
|
||||
*/
|
||||
static createDirectories(directory: string) {
|
||||
return mkdirp(directory)
|
||||
static async createDirectories(directory: string): Promise<void> {
|
||||
await fs.mkdir(directory, { recursive: true })
|
||||
}
|
||||
|
||||
/**
|
||||
@ -79,26 +78,28 @@ export class CommandUtils {
|
||||
override: boolean = true,
|
||||
): Promise<void> {
|
||||
await CommandUtils.createDirectories(path.dirname(filePath))
|
||||
return new Promise<void>((ok, fail) => {
|
||||
if (override === false && fs.existsSync(filePath)) return ok()
|
||||
|
||||
fs.writeFile(filePath, content, (err) => (err ? fail(err) : ok()))
|
||||
})
|
||||
if (override === false && (await CommandUtils.fileExists(filePath))) {
|
||||
return
|
||||
}
|
||||
await fs.writeFile(filePath, content)
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads everything from a given file and returns its content as a string.
|
||||
*/
|
||||
static async readFile(filePath: string): Promise<string> {
|
||||
return new Promise<string>((ok, fail) => {
|
||||
fs.readFile(filePath, (err, data) =>
|
||||
err ? fail(err) : ok(data.toString()),
|
||||
)
|
||||
})
|
||||
const file = await fs.readFile(filePath)
|
||||
|
||||
return file.toString()
|
||||
}
|
||||
|
||||
static async fileExists(filePath: string) {
|
||||
return fs.existsSync(filePath)
|
||||
try {
|
||||
await fs.access(filePath, fs.constants.F_OK)
|
||||
return true
|
||||
} catch {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import mkdirp from "mkdirp"
|
||||
import fs from "fs/promises"
|
||||
import path from "path"
|
||||
import { DriverPackageNotInstalledError } from "../../error"
|
||||
import { PlatformTools } from "../../platform/PlatformTools"
|
||||
@ -187,7 +187,7 @@ export class BetterSqlite3Driver extends AbstractSqliteDriver {
|
||||
* Auto creates database directory if it does not exist.
|
||||
*/
|
||||
protected async createDatabaseDirectory(dbPath: string): Promise<void> {
|
||||
await mkdirp(dbPath)
|
||||
await fs.mkdir(dbPath, { recursive: true })
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import mkdirp from "mkdirp"
|
||||
import fs from "fs/promises"
|
||||
import path from "path"
|
||||
import { DriverPackageNotInstalledError } from "../../error/DriverPackageNotInstalledError"
|
||||
import { SqliteQueryRunner } from "./SqliteQueryRunner"
|
||||
@ -203,7 +203,7 @@ export class SqliteDriver extends AbstractSqliteDriver {
|
||||
* Auto creates database directory if it does not exist.
|
||||
*/
|
||||
protected async createDatabaseDirectory(fullPath: string): Promise<void> {
|
||||
await mkdirp(path.dirname(fullPath))
|
||||
await fs.mkdir(path.dirname(fullPath), { recursive: true })
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import * as path from "path"
|
||||
import * as fs from "fs"
|
||||
import path from "path"
|
||||
import fs from "fs"
|
||||
import dotenv from "dotenv"
|
||||
import chalk from "chalk"
|
||||
import { highlight, Theme } from "cli-highlight"
|
||||
@ -182,12 +182,7 @@ export class PlatformTools {
|
||||
}
|
||||
|
||||
static async writeFile(path: string, data: any): Promise<void> {
|
||||
return new Promise<void>((ok, fail) => {
|
||||
fs.writeFile(path, data, (err) => {
|
||||
if (err) fail(err)
|
||||
ok()
|
||||
})
|
||||
})
|
||||
return fs.promises.writeFile(path, data)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import fs from "fs"
|
||||
import fs from "fs/promises"
|
||||
import path from "path"
|
||||
import { pathToFileURL } from "url"
|
||||
|
||||
@ -39,45 +39,31 @@ export async function importOrRequireFile(
|
||||
return tryToRequire()
|
||||
}
|
||||
|
||||
function getNearestPackageJson(filePath: string): Promise<object | null> {
|
||||
return new Promise((accept) => {
|
||||
let currentPath = filePath
|
||||
async function getNearestPackageJson(filePath: string): Promise<object | null> {
|
||||
let currentPath = filePath
|
||||
|
||||
function searchPackageJson() {
|
||||
const nextPath = path.dirname(currentPath)
|
||||
while (currentPath !== path.dirname(currentPath)) {
|
||||
currentPath = path.dirname(currentPath)
|
||||
const potentialPackageJson = path.join(currentPath, "package.json")
|
||||
|
||||
if (currentPath === nextPath)
|
||||
// the top of the file tree is reached
|
||||
accept(null)
|
||||
else {
|
||||
currentPath = nextPath
|
||||
const potentialPackageJson = path.join(
|
||||
currentPath,
|
||||
"package.json",
|
||||
)
|
||||
|
||||
fs.stat(potentialPackageJson, (err, stats) => {
|
||||
if (err != null) searchPackageJson()
|
||||
else if (stats.isFile()) {
|
||||
fs.readFile(
|
||||
potentialPackageJson,
|
||||
"utf8",
|
||||
(err, data) => {
|
||||
if (err != null) accept(null)
|
||||
else {
|
||||
try {
|
||||
accept(JSON.parse(data))
|
||||
} catch (err) {
|
||||
accept(null)
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
} else searchPackageJson()
|
||||
})
|
||||
try {
|
||||
const stats = await fs.stat(potentialPackageJson)
|
||||
if (!stats.isFile()) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
searchPackageJson()
|
||||
})
|
||||
try {
|
||||
return JSON.parse(
|
||||
await fs.readFile(potentialPackageJson, "utf8"),
|
||||
)
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
} catch {
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
// the top of the file tree is reached
|
||||
return null
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { promises as fs } from "fs"
|
||||
import fs from "fs/promises"
|
||||
import { expect } from "chai"
|
||||
import { DataSourceOptions } from "../../../src/data-source/DataSourceOptions"
|
||||
import { ConnectionOptionsReader } from "../../../src/connection/ConnectionOptionsReader"
|
||||
|
||||
@ -11,9 +11,9 @@ import { Category } from "./entity/Category"
|
||||
import { Post } from "./entity/Post"
|
||||
import { User } from "./entity/User"
|
||||
import { filepathToName } from "../../../../src/util/PathUtils"
|
||||
import rimraf from "rimraf"
|
||||
import { rimraf } from "rimraf"
|
||||
import path from "path"
|
||||
import fs from "fs"
|
||||
import fs from "fs/promises"
|
||||
import appRoot from "app-root-path"
|
||||
|
||||
const VALID_NAME_REGEX = /^(?!sqlite_).{1,63}$/
|
||||
@ -104,9 +104,13 @@ describe("multi-database > basic-functionality", () => {
|
||||
)!.groups!["filename"],
|
||||
)
|
||||
|
||||
expect(fs.existsSync(expectedMainPath)).to.be.true
|
||||
expect(fs.existsSync(attachAnswerPath)).to.be.true
|
||||
expect(fs.existsSync(attachCategoryPath)).to.be.true
|
||||
await expect(fs.access(expectedMainPath, fs.constants.F_OK))
|
||||
.to.not.be.rejected
|
||||
await expect(fs.access(attachAnswerPath, fs.constants.F_OK))
|
||||
.to.not.be.rejected
|
||||
await expect(
|
||||
fs.access(attachCategoryPath, fs.constants.F_OK),
|
||||
).to.not.be.rejected
|
||||
}),
|
||||
))
|
||||
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
import "reflect-metadata"
|
||||
import fs from "fs/promises"
|
||||
import { expect } from "chai"
|
||||
import sinon from "sinon"
|
||||
import {
|
||||
closeTestingConnections,
|
||||
createTestingConnections,
|
||||
@ -11,11 +13,7 @@ import { User } from "./entity/User"
|
||||
import { Category } from "./entity/Category"
|
||||
import { Post } from "./entity/Post"
|
||||
import { Photo } from "./entity/Photo"
|
||||
import sinon from "sinon"
|
||||
import { FileLogger } from "../../../../src"
|
||||
import { promisify } from "util"
|
||||
import fs from "fs"
|
||||
import { readFile, unlink } from "fs"
|
||||
|
||||
describe("repository > find options", () => {
|
||||
let connections: DataSource[]
|
||||
@ -256,9 +254,9 @@ describe("repository > find options > comment", () => {
|
||||
beforeEach(() => reloadTestingDatabases(connections))
|
||||
after(async () => {
|
||||
await closeTestingConnections(connections)
|
||||
if (fs.existsSync(logPath)) {
|
||||
await promisify(unlink)(logPath)
|
||||
}
|
||||
try {
|
||||
await fs.unlink(logPath)
|
||||
} catch {}
|
||||
})
|
||||
|
||||
it("repository should insert comment", () =>
|
||||
@ -268,7 +266,7 @@ describe("repository > find options > comment", () => {
|
||||
.getRepository(User)
|
||||
.find({ comment: "This is a query comment." })
|
||||
|
||||
const logs = await promisify(readFile)(logPath)
|
||||
const logs = await fs.readFile(logPath)
|
||||
const lines = logs.toString().split("\n")
|
||||
const lastLine = lines[lines.length - 2] // last line is blank after newline
|
||||
// remove timestamp and prefix
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import "reflect-metadata"
|
||||
import * as fs from "fs"
|
||||
import fs from "fs/promises"
|
||||
import { expect } from "chai"
|
||||
import {
|
||||
closeTestingConnections,
|
||||
@ -41,7 +41,7 @@ describe("sqljs driver > load", () => {
|
||||
const exportedDatabase =
|
||||
dataSource.sqljsManager.exportDatabase()
|
||||
expect(exportedDatabase).not.to.be.undefined
|
||||
const originalFileContent = fs.readFileSync(
|
||||
const originalFileContent = await fs.readFile(
|
||||
"test/functional/sqljs/sqlite/test.sqlite",
|
||||
)
|
||||
expect(exportedDatabase.length).to.equal(
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import "reflect-metadata"
|
||||
import * as fs from "fs"
|
||||
import * as path from "path"
|
||||
import fs from "fs/promises"
|
||||
import path from "path"
|
||||
import { expect } from "chai"
|
||||
import {
|
||||
closeTestingConnections,
|
||||
@ -28,18 +28,19 @@ describe("sqljs driver > save", () => {
|
||||
it("should save to file", () =>
|
||||
Promise.all(
|
||||
connections.map(async (dataSource) => {
|
||||
if (fs.existsSync(pathToSqlite)) {
|
||||
fs.unlinkSync(pathToSqlite)
|
||||
}
|
||||
try {
|
||||
await fs.unlink(pathToSqlite)
|
||||
} catch {}
|
||||
|
||||
let post = new Post()
|
||||
const post = new Post()
|
||||
post.title = "The second title"
|
||||
|
||||
const repository = dataSource.getRepository(Post)
|
||||
await repository.save(post)
|
||||
|
||||
await dataSource.sqljsManager.saveDatabase(pathToSqlite)
|
||||
expect(fs.existsSync(pathToSqlite)).to.be.true
|
||||
await expect(fs.access(pathToSqlite, fs.constants.F_OK)).not.to
|
||||
.be.rejected
|
||||
}),
|
||||
))
|
||||
|
||||
|
||||
@ -1,14 +1,9 @@
|
||||
import { expect } from "chai"
|
||||
import fs from "fs"
|
||||
import fs from "fs/promises"
|
||||
import path from "path"
|
||||
import { importOrRequireFile } from "../../../src/util/ImportUtils"
|
||||
|
||||
describe("ImportUtils.importOrRequireFile", () => {
|
||||
const rmdirSync = (dir: string) => {
|
||||
if (fs.rmSync != null) fs.rmSync(dir, { recursive: true })
|
||||
else fs.rmdirSync(dir, { recursive: true })
|
||||
}
|
||||
|
||||
it("should import .js file as ESM", async () => {
|
||||
const testDir = path.join(__dirname, "testJsEsm")
|
||||
const srcDir = path.join(testDir, "src")
|
||||
@ -23,16 +18,18 @@ describe("ImportUtils.importOrRequireFile", () => {
|
||||
export const number = 6;
|
||||
`
|
||||
|
||||
if (fs.existsSync(testDir)) rmdirSync(testDir)
|
||||
try {
|
||||
await fs.rmdir(testDir, { recursive: true })
|
||||
} catch {}
|
||||
|
||||
fs.mkdirSync(srcDir, { recursive: true })
|
||||
await fs.mkdir(srcDir, { recursive: true })
|
||||
|
||||
fs.writeFileSync(
|
||||
await fs.writeFile(
|
||||
packageJsonPath,
|
||||
JSON.stringify(packageJsonContent),
|
||||
"utf8",
|
||||
)
|
||||
fs.writeFileSync(jsFilePath, jsFileContent, "utf8")
|
||||
await fs.writeFile(jsFilePath, jsFileContent, "utf8")
|
||||
|
||||
const [exports, moduleType] = await importOrRequireFile(jsFilePath)
|
||||
|
||||
@ -41,7 +38,7 @@ describe("ImportUtils.importOrRequireFile", () => {
|
||||
expect(exports.default).to.be.a("function")
|
||||
expect(exports.number).to.be.eq(6)
|
||||
|
||||
rmdirSync(testDir)
|
||||
await fs.rmdir(testDir, { recursive: true })
|
||||
})
|
||||
|
||||
it("should import .js file as CommonJS", async () => {
|
||||
@ -60,16 +57,18 @@ describe("ImportUtils.importOrRequireFile", () => {
|
||||
};
|
||||
`
|
||||
|
||||
if (fs.existsSync(testDir)) rmdirSync(testDir)
|
||||
try {
|
||||
await fs.rmdir(testDir, { recursive: true })
|
||||
} catch {}
|
||||
|
||||
fs.mkdirSync(srcDir, { recursive: true })
|
||||
await fs.mkdir(srcDir, { recursive: true })
|
||||
|
||||
fs.writeFileSync(
|
||||
await fs.writeFile(
|
||||
packageJsonPath,
|
||||
JSON.stringify(packageJsonContent),
|
||||
"utf8",
|
||||
)
|
||||
fs.writeFileSync(jsFilePath, jsFileContent, "utf8")
|
||||
await fs.writeFile(jsFilePath, jsFileContent, "utf8")
|
||||
|
||||
const [exports, moduleType] = await importOrRequireFile(jsFilePath)
|
||||
|
||||
@ -78,7 +77,7 @@ describe("ImportUtils.importOrRequireFile", () => {
|
||||
expect(exports.test).to.be.a("function")
|
||||
expect(exports.number).to.be.eq(6)
|
||||
|
||||
rmdirSync(testDir)
|
||||
await fs.rmdir(testDir, { recursive: true })
|
||||
})
|
||||
|
||||
it("should import .mjs file as ESM", async () => {
|
||||
@ -92,11 +91,13 @@ describe("ImportUtils.importOrRequireFile", () => {
|
||||
export const number = 6;
|
||||
`
|
||||
|
||||
if (fs.existsSync(testDir)) rmdirSync(testDir)
|
||||
try {
|
||||
await fs.rmdir(testDir, { recursive: true })
|
||||
} catch {}
|
||||
|
||||
fs.mkdirSync(srcDir, { recursive: true })
|
||||
await fs.mkdir(srcDir, { recursive: true })
|
||||
|
||||
fs.writeFileSync(jsFilePath, jsFileContent, "utf8")
|
||||
await fs.writeFile(jsFilePath, jsFileContent, "utf8")
|
||||
|
||||
const [exports, moduleType] = await importOrRequireFile(jsFilePath)
|
||||
|
||||
@ -105,7 +106,7 @@ describe("ImportUtils.importOrRequireFile", () => {
|
||||
expect(exports.default).to.be.a("function")
|
||||
expect(exports.number).to.be.eq(6)
|
||||
|
||||
rmdirSync(testDir)
|
||||
await fs.rmdir(testDir, { recursive: true })
|
||||
})
|
||||
|
||||
it("should import .cjs file as CommonJS", async () => {
|
||||
@ -121,11 +122,13 @@ describe("ImportUtils.importOrRequireFile", () => {
|
||||
};
|
||||
`
|
||||
|
||||
if (fs.existsSync(testDir)) rmdirSync(testDir)
|
||||
try {
|
||||
await fs.rmdir(testDir, { recursive: true })
|
||||
} catch {}
|
||||
|
||||
fs.mkdirSync(srcDir, { recursive: true })
|
||||
await fs.mkdir(srcDir, { recursive: true })
|
||||
|
||||
fs.writeFileSync(jsFilePath, jsFileContent, "utf8")
|
||||
await fs.writeFile(jsFilePath, jsFileContent, "utf8")
|
||||
|
||||
const [exports, moduleType] = await importOrRequireFile(jsFilePath)
|
||||
|
||||
@ -134,7 +137,7 @@ describe("ImportUtils.importOrRequireFile", () => {
|
||||
expect(exports.test).to.be.a("function")
|
||||
expect(exports.number).to.be.eq(6)
|
||||
|
||||
rmdirSync(testDir)
|
||||
await fs.rmdir(testDir, { recursive: true })
|
||||
})
|
||||
|
||||
it("should import .json file as CommonJS", async () => {
|
||||
@ -143,11 +146,17 @@ describe("ImportUtils.importOrRequireFile", () => {
|
||||
const jsonFilePath = path.join(testDir, "file.json")
|
||||
const jsonFileContent = { test: 6 }
|
||||
|
||||
if (fs.existsSync(testDir)) rmdirSync(testDir)
|
||||
try {
|
||||
await fs.rmdir(testDir, { recursive: true })
|
||||
} catch {}
|
||||
|
||||
fs.mkdirSync(testDir, { recursive: true })
|
||||
await fs.mkdir(testDir, { recursive: true })
|
||||
|
||||
fs.writeFileSync(jsonFilePath, JSON.stringify(jsonFileContent), "utf8")
|
||||
await fs.writeFile(
|
||||
jsonFilePath,
|
||||
JSON.stringify(jsonFileContent),
|
||||
"utf8",
|
||||
)
|
||||
|
||||
const [exports, moduleType] = await importOrRequireFile(jsonFilePath)
|
||||
|
||||
@ -155,6 +164,6 @@ describe("ImportUtils.importOrRequireFile", () => {
|
||||
expect(moduleType).to.be.eq("commonjs")
|
||||
expect(exports.test).to.be.eq(6)
|
||||
|
||||
rmdirSync(testDir)
|
||||
await fs.rmdir(testDir, { recursive: true })
|
||||
})
|
||||
})
|
||||
|
||||
@ -1,38 +1,46 @@
|
||||
import { expect } from "chai"
|
||||
import { writeFileSync, unlinkSync } from "fs"
|
||||
import { writeFile, unlink } from "fs/promises"
|
||||
import { ConnectionOptionsReader } from "../../../src/connection/ConnectionOptionsReader"
|
||||
import { importClassesFromDirectories } from "../../../src/util/DirectoryExportedClassesLoader"
|
||||
import { LoggerFactory } from "../../../src/logger/LoggerFactory"
|
||||
import { DataSourceOptions } from "../../../src/data-source/DataSourceOptions"
|
||||
|
||||
describe("github issues > #6284 cli support for cjs extension", () => {
|
||||
it("will load a cjs file", async () => {
|
||||
const cjsConfigPath = [__dirname, "ormconfig.cjs"].join("/")
|
||||
const databaseType = "postgres"
|
||||
const config = `module.exports = {"type": "${databaseType}"};`
|
||||
let results: DataSourceOptions[]
|
||||
|
||||
writeFileSync(cjsConfigPath, config)
|
||||
const reader = new ConnectionOptionsReader({ root: __dirname })
|
||||
await writeFile(cjsConfigPath, config)
|
||||
try {
|
||||
const reader = new ConnectionOptionsReader({ root: __dirname })
|
||||
results = await reader.all()
|
||||
} finally {
|
||||
await unlink(cjsConfigPath)
|
||||
}
|
||||
|
||||
const results = await reader.all()
|
||||
expect(results).to.be.an("Array")
|
||||
expect(results[0]).to.be.an("Object")
|
||||
expect(results[0].type).to.equal(databaseType)
|
||||
|
||||
unlinkSync(cjsConfigPath)
|
||||
})
|
||||
|
||||
it("loads cjs files via DirectoryExportedClassesloader", async () => {
|
||||
const klassPath = [__dirname, "klass.cjs"].join("/")
|
||||
const klass = `module.exports.Widget = class Widget {};`
|
||||
writeFileSync(klassPath, klass)
|
||||
let classes: Function[]
|
||||
|
||||
await writeFile(klassPath, klass)
|
||||
try {
|
||||
classes = await importClassesFromDirectories(
|
||||
new LoggerFactory().create(),
|
||||
[`${__dirname}/*.cjs`],
|
||||
)
|
||||
} finally {
|
||||
await unlink(klassPath)
|
||||
}
|
||||
|
||||
const classes = await importClassesFromDirectories(
|
||||
new LoggerFactory().create(),
|
||||
[`${__dirname}/*.cjs`],
|
||||
)
|
||||
expect(classes).to.be.an("Array")
|
||||
expect(classes.length).to.eq(1)
|
||||
|
||||
unlinkSync(klassPath)
|
||||
})
|
||||
})
|
||||
|
||||
@ -1,9 +1,8 @@
|
||||
import "reflect-metadata"
|
||||
import * as assert from "assert"
|
||||
import rimraf from "rimraf"
|
||||
import { expect } from "chai"
|
||||
import { dirname } from "path"
|
||||
import { DataSource } from "../../../src/data-source/DataSource"
|
||||
import { getTypeOrmConfig } from "../../utils/test-utils"
|
||||
import { rimraf } from "rimraf"
|
||||
|
||||
describe("github issues > #799 sqlite: 'database' path should be created", () => {
|
||||
let dataSource: DataSource
|
||||
@ -33,7 +32,7 @@ describe("github issues > #799 sqlite: 'database' path should be created", () =>
|
||||
})
|
||||
await dataSource.initialize()
|
||||
|
||||
assert.strictEqual(dataSource.isInitialized, true)
|
||||
expect(dataSource.isInitialized).to.equal(true)
|
||||
})
|
||||
|
||||
it("should create the whole path to database file for better-sqlite3", async function () {
|
||||
@ -50,6 +49,6 @@ describe("github issues > #799 sqlite: 'database' path should be created", () =>
|
||||
})
|
||||
await dataSource.initialize()
|
||||
|
||||
assert.strictEqual(dataSource.isInitialized, true)
|
||||
expect(dataSource.isInitialized).to.equal(true)
|
||||
})
|
||||
})
|
||||
|
||||
@ -1,8 +1,7 @@
|
||||
import { expect } from "chai"
|
||||
import { exec } from "child_process"
|
||||
import { readFileSync, writeFileSync } from "fs"
|
||||
import { readFile, writeFile, chmod, unlink, rmdir } from "fs/promises"
|
||||
import { dirname } from "path"
|
||||
import rimraf from "rimraf"
|
||||
|
||||
describe("cli init command", () => {
|
||||
const cliPath = `${dirname(dirname(dirname(__dirname)))}/src/cli.js`
|
||||
@ -21,39 +20,33 @@ describe("cli init command", () => {
|
||||
const builtSrcDirectory = "build/compiled/src"
|
||||
|
||||
before(async () => {
|
||||
const chmodPromise = new Promise<void>((resolve) => {
|
||||
exec(`chmod 755 ${cliPath}`, (error, stdout, stderr) => {
|
||||
expect(error).to.not.exist
|
||||
expect(stderr).to.be.empty
|
||||
const chmodCli = async () => {
|
||||
await expect(chmod(cliPath, 0o755)).to.not.be.rejected
|
||||
}
|
||||
|
||||
resolve()
|
||||
})
|
||||
})
|
||||
|
||||
const copyPromise = new Promise<void>(async (resolve) => {
|
||||
const copyPackageJson = async () => {
|
||||
// load package.json from the root of the project
|
||||
const packageJson = JSON.parse(
|
||||
readFileSync("./package.json", "utf8"),
|
||||
await readFile("./package.json", "utf8"),
|
||||
)
|
||||
packageJson.version = `0.0.0` // install no version but
|
||||
packageJson.installFrom = `file:../${builtSrcDirectory}` // use the built src directory
|
||||
// write the modified package.json to the build directory
|
||||
writeFileSync(
|
||||
await writeFile(
|
||||
`./${builtSrcDirectory}/package.json`,
|
||||
JSON.stringify(packageJson, null, 4),
|
||||
)
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
|
||||
await Promise.all([chmodPromise, copyPromise])
|
||||
await Promise.all([chmodCli(), copyPackageJson()])
|
||||
})
|
||||
|
||||
after(async () => {
|
||||
await rimraf(`./${builtSrcDirectory}/package.json`)
|
||||
await unlink(`./${builtSrcDirectory}/package.json`)
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
await rimraf(`./${testProjectName}`)
|
||||
await rmdir(`./${testProjectName}`, { recursive: true })
|
||||
})
|
||||
|
||||
for (const databaseOption of databaseOptions) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user