Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration branch for PR #1267 #1278

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
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
128 changes: 63 additions & 65 deletions common/config/rush/pnpm-lock.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/chapters/02_getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ and 'production environments –
"lint:fix": "eslint --quiet --fix --ext '.js,.ts' **/*.ts",
"build": "ttsc -b tsconfig.json",
"clean": "rimraf ./dist tsconfig.tsbuildinfo",
"test": "AWS_SDK_LOAD_CONFIG=true BOOSTER_ENV=test nyc --extension .ts mocha --forbid-only \"test/**/*.test.ts\""
"test": "cross-env AWS_SDK_LOAD_CONFIG=true cross-env BOOSTER_ENV=test nyc --extension .ts mocha --forbid-only \"test/**/*.test.ts\""
},
...
```
Expand Down
2 changes: 1 addition & 1 deletion docs/chapters/06_testing-booster-applications.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ The only thing that you should add to this line are the `AWS_SDK_LOAD_CONFIG=tru

```typescript
"scripts": {
"test": "AWS_SDK_LOAD_CONFIG=true BOOSTER_ENV=test nyc --extension .ts mocha --forbid-only \"test/**/*.test.ts\""
"test": "cross-env AWS_SDK_LOAD_CONFIG=true cross-env BOOSTER_ENV=test nyc --extension .ts mocha --forbid-only \"test/**/*.test.ts\""
}
```

Expand Down
3 changes: 2 additions & 1 deletion packages/cli/test/commands/new/command.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ import * as fs from 'fs-extra'
import { IConfig } from '@oclif/config'
import { expect } from '../../expect'
import { template } from '../../../src/services/generator'
import * as path from 'path'

describe('new', (): void => {
describe('Command', () => {
const command = 'ExampleCommand'
const commandsRoot = 'src/commands/'
const commandPath = `${commandsRoot}example-command.ts`
const commandPath = path.normalize(`${commandsRoot}example-command.ts`)
const defaultCommandImports = [
{
packagePath: '@boostercloud/framework-core',
Expand Down
3 changes: 2 additions & 1 deletion packages/cli/test/commands/new/entity.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ import * as fs from 'fs-extra'
import { IConfig } from '@oclif/config'
import { expect } from '../../expect'
import { template } from '../../../src/services/generator'
import * as path from 'path'

describe('new', (): void => {
describe('Entity', () => {
const entityName = 'ExampleEntity'
const entitysRoot = 'src/entities/'
const entityPath = `${entitysRoot}example-entity.ts`
const entityPath = path.normalize(`${entitysRoot}example-entity.ts`)
const defaultEntityImports = [
{
packagePath: '@boostercloud/framework-core',
Expand Down
3 changes: 2 additions & 1 deletion packages/cli/test/commands/new/event-handler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ import * as fs from 'fs-extra'
import { IConfig } from '@oclif/config'
import { expect } from '../../expect'
import { template } from '../../../src/services/generator'
import * as path from 'path'

describe('new', (): void => {
describe('Event', () => {
const eventHandlerName = 'ExampleEventHandler'
const eventHandlersRoot = 'src/event-handlers/'
const eventHandlerPath = `${eventHandlersRoot}example-event-handler.ts`
const eventHandlerPath = path.normalize(`${eventHandlersRoot}example-event-handler.ts`)
const defaultEventHandlerImports = [
{
packagePath: '../events/comment-posted',
Expand Down
3 changes: 2 additions & 1 deletion packages/cli/test/commands/new/event.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ import * as fs from 'fs-extra'
import { IConfig } from '@oclif/config'
import { expect } from '../../expect'
import { template } from '../../../src/services/generator'
import * as path from 'path'

describe('new', (): void => {
describe('Event', () => {
const eventName = 'ExampleEvent'
const eventsRoot = 'src/events/'
const eventPath = `${eventsRoot}example-event.ts`
const eventPath = path.normalize(`${eventsRoot}example-event.ts`)
const defaultEventImports = [
{
packagePath: '@boostercloud/framework-core',
Expand Down
69 changes: 35 additions & 34 deletions packages/cli/test/commands/new/project.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import * as Project from '../../../src/commands/new/project'
import * as ProjectInitializer from '../../../src/services/project-initializer'
import * as packageJson from '../../../src/templates/project/package-json'
import * as Mustache from 'mustache'
import * as path from 'path'

describe('new', (): void => {
describe('project', () => {
Expand All @@ -17,24 +18,24 @@ describe('new', (): void => {
const defaultRepository = 'github.com:boostercloud/booster.git'

const expectFilesAndDirectoriesCreated = (projectName: string) => {
expect(fs.mkdirs).to.have.been.calledWithMatch(`${projectName}/src/commands`)
expect(fs.mkdirs).to.have.been.calledWithMatch(`${projectName}/src/events`)
expect(fs.mkdirs).to.have.been.calledWithMatch(`${projectName}/src/entities`)
expect(fs.mkdirs).to.have.been.calledWithMatch(`${projectName}/src/read-models`)
expect(fs.mkdirs).to.have.been.calledWithMatch(`${projectName}/src/config`)
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.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`)
expect(fs.outputFile).to.have.been.calledWithMatch(`${projectName}/package.json`)
expect(fs.outputFile).to.have.been.calledWithMatch(`${projectName}/tsconfig.json`)
expect(fs.outputFile).to.have.been.calledWithMatch(`${projectName}/tsconfig.eslint.json`)
expect(fs.outputFile).to.have.been.calledWithMatch(`${projectName}/.prettierrc.yaml`)
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.mkdirs).to.have.been.calledWithMatch(path.normalize(`${projectName}/src/commands`))
expect(fs.mkdirs).to.have.been.calledWithMatch(path.normalize(`${projectName}/src/events`))
expect(fs.mkdirs).to.have.been.calledWithMatch(path.normalize(`${projectName}/src/entities`))
expect(fs.mkdirs).to.have.been.calledWithMatch(path.normalize(`${projectName}/src/read-models`))
expect(fs.mkdirs).to.have.been.calledWithMatch(path.normalize(`${projectName}/src/config`))
expect(fs.mkdirs).to.have.been.calledWithMatch(path.normalize(`${projectName}/src/common`))
expect(fs.mkdirs).to.have.been.calledWithMatch(path.normalize(`${projectName}/src/event-handlers`))
expect(fs.mkdirs).to.have.been.calledWithMatch(path.normalize(`${projectName}/src/scheduled-commands`))
expect(fs.outputFile).to.have.been.calledWithMatch(path.normalize(`${projectName}/.eslintignore`))
expect(fs.outputFile).to.have.been.calledWithMatch(path.normalize(`${projectName}/.eslintrc.js`))
expect(fs.outputFile).to.have.been.calledWithMatch(path.normalize(`${projectName}/.gitignore`))
expect(fs.outputFile).to.have.been.calledWithMatch(path.normalize(`${projectName}/package.json`))
expect(fs.outputFile).to.have.been.calledWithMatch(path.normalize(`${projectName}/tsconfig.json`))
expect(fs.outputFile).to.have.been.calledWithMatch(path.normalize(`${projectName}/tsconfig.eslint.json`))
expect(fs.outputFile).to.have.been.calledWithMatch(path.normalize(`${projectName}/.prettierrc.yaml`))
expect(fs.outputFile).to.have.been.calledWithMatch(path.normalize(`${projectName}/src/config/config.ts`))
expect(fs.outputFile).to.have.been.calledWithMatch(path.normalize(`${projectName}/src/index.ts`))
expect(fs.outputFile).to.have.been.calledWithMatch(path.normalize(`${projectName}/.mocharc.yml`))
}

const defaultProjectInitializerConfig = {
Expand Down Expand Up @@ -106,7 +107,7 @@ describe('new', (): void => {
)

const expectedPackageJson = renderPackageJson(defaultProjectInitializerConfig)
expect(fs.outputFile).to.have.been.calledWithMatch(`${projectName}/package.json`,expectedPackageJson)
expect(fs.outputFile).to.have.been.calledWithMatch(path.normalize(`${projectName}/package.json`),expectedPackageJson)
expect(ProjectInitializer.installDependencies).to.have.been.called
})

Expand All @@ -119,7 +120,7 @@ describe('new', (): void => {
expect(ProjectInitializer.initializeGit).to.have.not.been.called
expectFilesAndDirectoriesCreated(projectName)
const expectedPackageJson = renderPackageJson(defaultProjectInitializerConfig)
expect(fs.outputFile).to.have.been.calledWithMatch(`${projectName}/package.json`,expectedPackageJson)
expect(fs.outputFile).to.have.been.calledWithMatch(path.normalize(`${projectName}/package.json`),expectedPackageJson)
})

describe('define homepage', () => {
Expand All @@ -133,7 +134,7 @@ describe('new', (): void => {
expect(ProjectInitializer.installDependencies).to.have.been.called
expect(oraLogger.info).to.have.been.calledWithMatch('Project generated!')
expectFilesAndDirectoriesCreated(projectName)
expect(fs.outputFile).to.have.been.calledWithMatch(`${projectName}/package.json`,renderPackageJson(config))
expect(fs.outputFile).to.have.been.calledWithMatch(path.normalize(`${projectName}/package.json`),renderPackageJson(config))
})

it('with -H', async () => {
Expand All @@ -146,7 +147,7 @@ describe('new', (): void => {
expect(ProjectInitializer.installDependencies).to.have.been.called
expect(oraLogger.info).to.have.been.calledWithMatch('Project generated!')
expectFilesAndDirectoriesCreated(projectName)
expect(fs.outputFile).to.have.been.calledWithMatch(`${projectName}/package.json`,renderPackageJson(config))
expect(fs.outputFile).to.have.been.calledWithMatch(path.normalize(`${projectName}/package.json`),renderPackageJson(config))
})
})

Expand All @@ -161,7 +162,7 @@ describe('new', (): void => {
expect(ProjectInitializer.installDependencies).to.have.been.called
expect(oraLogger.info).to.have.been.calledWithMatch('Project generated!')
expectFilesAndDirectoriesCreated(projectName)
expect(fs.outputFile).to.have.been.calledWithMatch(`${projectName}/package.json`,renderPackageJson(config))
expect(fs.outputFile).to.have.been.calledWithMatch(path.normalize(`${projectName}/package.json`),renderPackageJson(config))
})

it('with -a', async () => {
Expand All @@ -174,7 +175,7 @@ describe('new', (): void => {
expect(ProjectInitializer.installDependencies).to.have.been.called
expect(oraLogger.info).to.have.been.calledWithMatch('Project generated!')
expectFilesAndDirectoriesCreated(projectName)
expect(fs.outputFile).to.have.been.calledWithMatch(`${projectName}/package.json`,renderPackageJson(config))
expect(fs.outputFile).to.have.been.calledWithMatch(path.normalize(`${projectName}/package.json`),renderPackageJson(config))
})
})

Expand All @@ -189,7 +190,7 @@ describe('new', (): void => {
expect(ProjectInitializer.installDependencies).to.have.been.called
expect(oraLogger.info).to.have.been.calledWithMatch('Project generated!')
expectFilesAndDirectoriesCreated(projectName)
expect(fs.outputFile).to.have.been.calledWithMatch(`${projectName}/package.json`,renderPackageJson(config))
expect(fs.outputFile).to.have.been.calledWithMatch(path.normalize(`${projectName}/package.json`),renderPackageJson(config))
})

it('with -d', async () => {
Expand All @@ -202,7 +203,7 @@ describe('new', (): void => {
expect(ProjectInitializer.installDependencies).to.have.been.called
expect(oraLogger.info).to.have.been.calledWithMatch('Project generated!')
expectFilesAndDirectoriesCreated(projectName)
expect(fs.outputFile).to.have.been.calledWithMatch(`${projectName}/package.json`,renderPackageJson(config))
expect(fs.outputFile).to.have.been.calledWithMatch(path.normalize(`${projectName}/package.json`),renderPackageJson(config))
})
})

Expand All @@ -217,7 +218,7 @@ describe('new', (): void => {
expect(ProjectInitializer.installDependencies).to.have.been.called
expect(oraLogger.info).to.have.been.calledWithMatch('Project generated!')
expectFilesAndDirectoriesCreated(projectName)
expect(fs.outputFile).to.have.been.calledWithMatch(`${projectName}/package.json`,renderPackageJson(config))
expect(fs.outputFile).to.have.been.calledWithMatch(path.normalize(`${projectName}/package.json`),renderPackageJson(config))
})

it('with -l', async () => {
Expand All @@ -230,7 +231,7 @@ describe('new', (): void => {
expect(ProjectInitializer.installDependencies).to.have.been.called
expect(oraLogger.info).to.have.been.calledWithMatch('Project generated!')
expectFilesAndDirectoriesCreated(projectName)
expect(fs.outputFile).to.have.been.calledWithMatch(`${projectName}/package.json`,renderPackageJson(config))
expect(fs.outputFile).to.have.been.calledWithMatch(path.normalize(`${projectName}/package.json`),renderPackageJson(config))
})
})

Expand Down Expand Up @@ -269,7 +270,7 @@ describe('new', (): void => {
expect(ProjectInitializer.installDependencies).to.have.been.called
expect(oraLogger.info).to.have.been.calledWithMatch('Project generated!')
expectFilesAndDirectoriesCreated(projectName)
expect(fs.outputFile).to.have.been.calledWithMatch(`${projectName}/package.json`,renderPackageJson(config))
expect(fs.outputFile).to.have.been.calledWithMatch(path.normalize(`${projectName}/package.json`),renderPackageJson(config))
})

it('with -r', async () => {
Expand All @@ -282,7 +283,7 @@ describe('new', (): void => {
expect(ProjectInitializer.installDependencies).to.have.been.called
expect(oraLogger.info).to.have.been.calledWithMatch('Project generated!')
expectFilesAndDirectoriesCreated(projectName)
expect(fs.outputFile).to.have.been.calledWithMatch(`${projectName}/package.json`,renderPackageJson(config))
expect(fs.outputFile).to.have.been.calledWithMatch(path.normalize(`${projectName}/package.json`),renderPackageJson(config))
})
})

Expand All @@ -297,7 +298,7 @@ describe('new', (): void => {
expect(ProjectInitializer.installDependencies).to.have.been.called
expect(oraLogger.info).to.have.been.calledWithMatch('Project generated!')
expectFilesAndDirectoriesCreated(projectName)
expect(fs.outputFile).to.have.been.calledWithMatch(`${projectName}/package.json`,renderPackageJson(config))
expect(fs.outputFile).to.have.been.calledWithMatch(path.normalize(`${projectName}/package.json`),renderPackageJson(config))
})

it('with -v', async () => {
Expand All @@ -310,7 +311,7 @@ describe('new', (): void => {
expect(ProjectInitializer.installDependencies).to.have.been.called
expect(oraLogger.info).to.have.been.calledWithMatch('Project generated!')
expectFilesAndDirectoriesCreated(projectName)
expect(fs.outputFile).to.have.been.calledWithMatch(`${projectName}/package.json`,renderPackageJson(config))
expect(fs.outputFile).to.have.been.calledWithMatch(path.normalize(`${projectName}/package.json`),renderPackageJson(config))
})
})

Expand Down Expand Up @@ -359,7 +360,7 @@ describe('new', (): void => {
it('with empty project name', async () => {
replace(console,'error', fake.resolves({}))
await new Project.default([], {} as IConfig).run()
expect(fs.mkdirs).to.have.not.been.calledWithMatch(`${projectName}/src`)
expect(fs.mkdirs).to.have.not.been.calledWithMatch(path.normalize(`${projectName}/src`))
expect(console.error).to.have.been.calledWithMatch(/You haven't provided a project name/)
expect(oraLogger.info).to.have.not.been.calledWithMatch('Project generated!')
})
Expand All @@ -376,7 +377,7 @@ describe('new', (): void => {
expect(exceptionThrown).to.be.equal(true)
expect(exceptionMessage).to.contain('Unexpected argument: --nonexistingoption')
expect(oraLogger.info).to.have.not.been.calledWithMatch('Project generated!')
expect(fs.mkdirs).to.have.not.been.calledWithMatch(`${projectName}/src`)
expect(fs.mkdirs).to.have.not.been.calledWithMatch(path.normalize(`${projectName}/src`))
})

describe('define homepage badly', () => {
Expand Down
5 changes: 3 additions & 2 deletions packages/cli/test/commands/new/read-model.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ import * as fs from 'fs-extra'
import { IConfig } from '@oclif/config'
import { expect } from '../../expect'
import { template } from '../../../src/services/generator'
import * as path from 'path'

describe('new', (): void => {
describe('ReadModel', () => {
const readModelName = 'ExampleReadModel'
const readModelsRoot = 'src/read-models/'
const readModelPath = `${readModelsRoot}example-read-model.ts`
const readModelsRoot = path.normalize('src/read-models/')
const readModelPath = path.normalize(`${readModelsRoot}example-read-model.ts`)
const defaultReadModelImports = [
{
packagePath: '@boostercloud/framework-core',
Expand Down
3 changes: 2 additions & 1 deletion packages/cli/test/commands/new/scheduled-command.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ import * as fs from 'fs-extra'
import { IConfig } from '@oclif/config'
import { expect } from '../../expect'
import { template } from '../../../src/services/generator'
import * as path from 'path'

describe('new', (): void => {
describe('ScheduledCommand', () => {
const scheduledCommandName = 'ExampleScheduledCommand'
const scheduledCommandRoot = 'src/scheduled-commands/'
const scheduledCommandRoot = path.normalize('src/scheduled-commands/')
const scheduledCommandPath = `${scheduledCommandRoot}example-scheduled-command.ts`
const defaultScheduledCommandImports = [
{
Expand Down
3 changes: 2 additions & 1 deletion packages/cli/test/commands/new/type.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ import * as fs from 'fs-extra'
import { IConfig } from '@oclif/config'
import { expect } from '../../expect'
import { template } from '../../../src/services/generator'
import * as path from 'path'

describe('new', (): void => {
describe('Type', () => {
const typeName = 'ExampleType'
const typesRoot = 'src/common/'
const typesRoot = path.normalize('src/common/')
const typePath = `${typesRoot}example-type.ts`
const defaultTypeImports = [
{
Expand Down
Loading