Skip to content

Commit

Permalink
refactor(environments): [CreateCommand] #name -> #environment
Browse files Browse the repository at this point in the history
Signed-off-by: Lexus Drumgold <[email protected]>
  • Loading branch information
unicornware committed Nov 23, 2023
1 parent 76762c8 commit bfbaf8b
Show file tree
Hide file tree
Showing 13 changed files with 36 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .github/infrastructure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ branches:
- flex-development
status_checks: null
environments:
- name: release
- environment: release
prevent_self_review: false
reviewers: null
wait_timer: null
Expand Down
4 changes: 2 additions & 2 deletions .schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@
"items": {
"additionalProperties": false,
"properties": {
"name": {
"environment": {
"description": "environment name",
"minLength": 1,
"type": "string"
Expand Down Expand Up @@ -363,7 +363,7 @@
}
},
"required": [
"name"
"environment"
],
"type": "object"
},
Expand Down
14 changes: 7 additions & 7 deletions dist/main.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -95421,7 +95421,7 @@ var schema_default = {
items: {
additionalProperties: false,
properties: {
name: {
environment: {
description: "environment name",
minLength: 1,
type: "string"
Expand Down Expand Up @@ -95473,7 +95473,7 @@ var schema_default = {
}
},
required: [
"name"
"environment"
],
type: "object"
},
Expand Down Expand Up @@ -98425,17 +98425,17 @@ var CreateEnvironmentCommand = class extends environment_dto_default {
* @public
* @readonly
* @instance
* @member {Environment['name']} name
* @member {Environment['name']} environment
*/
name;
environment;
/**
* Create a new environment creation command.
*
* @param {CreateEnvironmentCommand} params - Command parameters
*/
constructor(params) {
super(params);
this.name = params.name;
this.environment = params.environment;
}
};
var create_command_default2 = CreateEnvironmentCommand;
Expand Down Expand Up @@ -98545,7 +98545,7 @@ var CreateEnvironmentHandler = class CreateEnvironmentHandler2 {
const { payload } = await this.octokit.graphql({
input: {
clientMutationId: this.config.get("id"),
name: command.name,
name: command.environment,
repositoryId: this.config.get("node_id")
},
query: this.operation
Expand Down Expand Up @@ -98839,7 +98839,7 @@ var ManageEnvironmentsHandler = class ManageEnvironmentsHandler2 extends manage_
* @return {Promise<Environment[]>} Managed environments
*/
async execute(command) {
return this.manage(["name"], command.environments, environments_query_default, delete_command_default2, create_command_default2, update_command_default2);
return this.manage(["name", "environment"], command.environments, environments_query_default, delete_command_default2, create_command_default2, update_command_default2);
}
};
ManageEnvironmentsHandler = __decorate22([
Expand Down
2 changes: 1 addition & 1 deletion dist/main.mjs.map

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions src/__tests__/runner.module.integration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,11 @@ describe('integration:RunnerModule', () => {
}
],
environments: [
at(api.graphql.repository.environments.nodes, -1),
{
name: 'docs',
environment: at(api.graphql.repository.environments.nodes, -1)!.name
},
{
environment: 'docs',
reviewers: { users: [get(api.graphql.users, '0.login')] }
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ describe('unit-d:environments/commands/CreateEnvironmentCommand', () => {
expectTypeOf<keyof TestSubject>().toEqualTypeOf<ReadonlyKeys<TestSubject>>()
})

it('should match [name: Environment["name"]]', () => {
it('should match [environment: Environment["name"]]', () => {
expectTypeOf<TestSubject>()
.toHaveProperty('name')
.toHaveProperty('environment')
.toEqualTypeOf<Environment['name']>()
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ import TestSubject from '../create.command'

describe('unit:environments/commands/CreateEnvironmentCommand', () => {
describe('constructor', () => {
let name: string
let environment: string
let subject: TestSubject

beforeAll(() => {
subject = new TestSubject({ name: name = 'production' })
subject = new TestSubject({ environment: environment = 'production' })
})

it('should set #name', () => {
expect(subject).to.have.property('name', name)
it('should set #environment', () => {
expect(subject).to.have.property('environment', environment)
})
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ describe('functional:environments/commands/CreateEnvironmentHandler', () => {

beforeAll(() => {
command = new CreateEnvironmentCommand({
name: 'production',
environment: 'production',
reviewers: { users: [get(api.graphql.users, '0.login')] }
})
})
Expand All @@ -69,7 +69,7 @@ describe('functional:environments/commands/CreateEnvironmentHandler', () => {
expect(octokit.graphql).toHaveBeenNthCalledWith(1, {
input: {
clientMutationId: CLIENT_MUTATION_ID,
name: command.name,
name: command.environment,
repositoryId: api.graphql.repository.id
},
query: get(subject, 'operation', <Optional<string>>undefined)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/

import api from '#fixtures/api.github.json' assert { type: 'json' }
import { select } from '@flex-development/tutils'
import CreateEnvironmentCommand from '../create.command'
import TestSubject from '../manage.command'

Expand All @@ -12,7 +13,11 @@ describe('unit:environments/commands/ManageEnvironmentsCommand', () => {
let subject: TestSubject

beforeAll(() => {
subject = new TestSubject(api.graphql.repository.environments.nodes)
subject = new TestSubject(
select(api.graphql.repository.environments.nodes, null, env => ({
environment: env.name
}))
)
})

it('should set #environments', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ describe('functional:environments/commands/ManageEnvironmentsHandler', () => {
beforeAll(() => {
incoming = [
{
name: 'marketplace',
environment: 'marketplace',
reviewers: {
teams: [get(api.graphql.organization.teams.nodes, '0.slug')],
users: [get(api.graphql.users, '0.login')]
Expand All @@ -76,7 +76,7 @@ describe('functional:environments/commands/ManageEnvironmentsHandler', () => {
]

nodes = api.graphql.repository.environments.nodes
current = [at(nodes, -1)]
current = [{ environment: at(nodes, -1)!.name }]
})

beforeEach(() => {
Expand Down
6 changes: 3 additions & 3 deletions src/subdomains/environments/commands/create.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ class CreateEnvironmentCommand extends EnvironmentDTO {
* @public
* @readonly
* @instance
* @member {Environment['name']} name
* @member {Environment['name']} environment
*/
public readonly name: Environment['name']
public readonly environment: Environment['name']

/**
* Create a new environment creation command.
Expand All @@ -34,7 +34,7 @@ class CreateEnvironmentCommand extends EnvironmentDTO {
*/
constructor(params: CreateEnvironmentCommand) {
super(params)
this.name = params.name
this.environment = params.environment
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/subdomains/environments/commands/create.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class CreateEnvironmentHandler
} = await this.octokit.graphql<{ environment: Environment }>({
input: <CreateEnvironmentInput>{
clientMutationId: this.config.get<string>('id'),
name: command.name,
name: command.environment,
repositoryId: this.config.get<string>('node_id')
},
query: this.operation
Expand Down
2 changes: 1 addition & 1 deletion src/subdomains/environments/commands/manage.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class ManageEnvironmentsHandler
command: ManageEnvironmentsCommand
): Promise<Environment[]> {
return this.manage(
['name'],
['name', 'environment'],
command.environments,
EnvironmentsQuery,
DeleteEnvironmentCommand,
Expand Down

0 comments on commit bfbaf8b

Please sign in to comment.