Skip to content

Commit

Permalink
fix: resolve cli init peer dependency issues (#8977)
Browse files Browse the repository at this point in the history
* fix: resolve cli init peer dependency issues

Closes: #8975

* fix: bump timeout for a test that takes particularly long on Node 13
  • Loading branch information
ahmedosama94 authored Jun 22, 2022
1 parent 723f1e5 commit f7578d4
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/commands/InitCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -682,16 +682,16 @@ Steps to run this project:
packageJson.dependencies["pg"] = "^8.4.0"
break
case "sqlite":
packageJson.dependencies["sqlite3"] = "^4.0.3"
packageJson.dependencies["sqlite3"] = "^5.0.2"
break
case "better-sqlite3":
packageJson.dependencies["better-sqlite3"] = "^7.0.0"
break
case "oracle":
packageJson.dependencies["oracledb"] = "^1.13.1"
packageJson.dependencies["oracledb"] = "^5.1.0"
break
case "mssql":
packageJson.dependencies["mssql"] = "^4.0.4"
packageJson.dependencies["mssql"] = "^6.3.0"
break
case "mongodb":
packageJson.dependencies["mongodb"] = "^3.0.8"
Expand Down
76 changes: 76 additions & 0 deletions test/github-issues/8975/issue-8975.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import { expect } from "chai"
import { exec } from "child_process"
import { dirname } from "path"
import rimraf from "rimraf"

describe.only("cli init command", () => {
const cliPath = `${dirname(dirname(dirname(__dirname)))}/src/cli.js`
const databaseOptions = [
"mysql",
"mariadb",
"postgres",
"cockroachdb",
"sqlite",
"better-sqlite3",
"oracle",
"mssql",
"mongodb",
]
const testProjectName = Date.now() + "TestProject"
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

resolve()
})
})

const copyPromise = new Promise<void>((resolve) => {
exec(
`cp package.json ${builtSrcDirectory}`,
(error, stdout, stderr) => {
expect(error).to.not.exist
expect(stderr).to.be.empty

resolve()
},
)
})

await Promise.all([chmodPromise, copyPromise])
})

after((done) => {
rimraf(`./${builtSrcDirectory}/package.json`, (error) => {
expect(error).to.not.exist

done()
})
})

afterEach((done) => {
rimraf(`./${testProjectName}`, (error) => {
expect(error).to.not.exist

done()
})
})

for (const databaseOption of databaseOptions) {
it(`should work with ${databaseOption} option`, (done) => {
exec(
`${cliPath} init --name ${testProjectName} --database ${databaseOption}`,
(error, stdout, stderr) => {
expect(error).to.not.exist
expect(stderr).to.be.empty

done()
},
)
}).timeout(90000)
}
})

0 comments on commit f7578d4

Please sign in to comment.