Skip to content
Open
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@boostercloud/framework-core",
"comment": "Add automatic .vscode/launch.json generation for new projects",
"type": "patch"
}
],
"packageName": "@boostercloud/framework-core"
}
3 changes: 3 additions & 0 deletions packages/cli/src/services/project-initializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import * as configTs from '../templates/project/config-ts'
import * as indexTs from '../templates/project/index-ts'
import * as prettierRc from '../templates/project/prettierrc-yaml'
import * as mochaRc from '../templates/project/mocharc-yml'
import * as launchJson from '../templates/project/launch-json'
import { guardError, wrapExecError } from '../common/errors'
import { PackageManagerService } from './package-manager'
import { gen, mapError, pipe, unsafeRunEffect } from '@boostercloud/framework-types/dist/effect'
Expand Down Expand Up @@ -53,6 +54,7 @@ export async function generateRootDirectory(config: ProjectInitializerConfig): P
[srcDir, 'event-handlers'],
[srcDir, 'read-models'],
[srcDir, 'scheduled-commands'],
[projectDir(config), '.vscode'],
]
await Promise.all(dirs.map(createDirectory))
}
Expand Down Expand Up @@ -107,4 +109,5 @@ const filesToGenerate: Array<[Array<string>, string]> = [
[['src', 'config', 'config.ts'], configTs.template],
[['src', 'index.ts'], indexTs.template],
[['.mocharc.yml'], mochaRc.template],
[['.vscode', 'launch.json'], launchJson.template],
]
15 changes: 15 additions & 0 deletions packages/cli/src/templates/project/launch-json.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export const template = `{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"command": "rushx test",
"name": "Unit Tests",
"request": "launch",
"type": "node-terminal",
"cwd": "\${workspaceFolder}",
},
]
}`
2 changes: 2 additions & 0 deletions packages/cli/test/commands/new/project.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ describe('new', (): void => {
expect(fs.mkdirs).to.have.been.calledWithMatch(`${projectName}/src/common`)
expect(fs.mkdirs).to.have.been.calledWithMatch(`${projectName}/src/event-handlers`)
expect(fs.mkdirs).to.have.been.calledWithMatch(`${projectName}/src/scheduled-commands`)
expect(fs.mkdirs).to.have.been.calledWithMatch(`${projectName}/.vscode`)
expect(fs.outputFile).to.have.been.calledWithMatch(`${projectName}/.eslintignore`)
expect(fs.outputFile).to.have.been.calledWithMatch(`${projectName}/.eslintrc.js`)
expect(fs.outputFile).to.have.been.calledWithMatch(`${projectName}/.gitignore`)
Expand All @@ -35,6 +36,7 @@ describe('new', (): void => {
expect(fs.outputFile).to.have.been.calledWithMatch(`${projectName}/src/config/config.ts`)
expect(fs.outputFile).to.have.been.calledWithMatch(`${projectName}/src/index.ts`)
expect(fs.outputFile).to.have.been.calledWithMatch(`${projectName}/.mocharc.yml`)
expect(fs.outputFile).to.have.been.calledWithMatch(`${projectName}/.vscode/launch.json`)
}

const defaultProjectInitializerConfig = {
Expand Down
2 changes: 2 additions & 0 deletions packages/cli/test/services/project-initializer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ describe('project initializer', (): void => {
expect(fs.mkdirs).to.have.been.calledWithMatch(`${projectName}/src/common`)
expect(fs.mkdirs).to.have.been.calledWithMatch(`${projectName}/src/event-handlers`)
expect(fs.mkdirs).to.have.been.calledWithMatch(`${projectName}/src/scheduled-commands`)
expect(fs.mkdirs).to.have.been.calledWithMatch(`${projectName}/.vscode`)
})

it('install dependencies', async () => {
Expand All @@ -76,5 +77,6 @@ describe('project initializer', (): void => {
expect(fs.outputFile).to.have.been.calledWithMatch(`${projectName}/src/config/config.ts`)
expect(fs.outputFile).to.have.been.calledWithMatch(`${projectName}/src/index.ts`)
expect(fs.outputFile).to.have.been.calledWithMatch(`${projectName}/.mocharc.yml`)
expect(fs.outputFile).to.have.been.calledWithMatch(`${projectName}/.vscode/launch.json`)
})
})
Loading