Skip to content

Commit

Permalink
refactor: code formatting
Browse files Browse the repository at this point in the history
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
  • Loading branch information
Jérôme Benoit committed May 21, 2024
1 parent cffc32b commit 48847bc
Show file tree
Hide file tree
Showing 32 changed files with 513 additions and 168 deletions.
2 changes: 1 addition & 1 deletion skip-preinstall.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { env, exit } from 'node:process'

const skipPreinstall = parseInt(env.SKIP_PREINSTALL) || env.VCAP_APPLICATION != null
const skipPreinstall = Number.parseInt(env.SKIP_PREINSTALL) || env.VCAP_APPLICATION != null
if (skipPreinstall) {
// eslint-disable-next-line n/no-process-exit
exit()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -892,7 +892,9 @@
"username": "admin",
"password": "admin"
},
"dataPropertyOrder": { "&": ["baseUrl", "protocol", "version", "username", "password"] },
"dataPropertyOrder": {
"&": ["baseUrl", "protocol", "version", "username", "password"]
},
"color": null,
"isPrivate": false,
"metaSortKey": 1661789025528,
Expand Down
4 changes: 3 additions & 1 deletion src/assets/ui-protocol/Insomnia-CSSimulatorUIWSProtocol.json
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,9 @@
"protocol": "ui",
"version": "0.0.1"
},
"dataPropertyOrder": { "&": ["baseUrl", "username", "password", "protocol", "version"] },
"dataPropertyOrder": {
"&": ["baseUrl", "username", "password", "protocol", "version"]
},
"color": null,
"isPrivate": false,
"metaSortKey": 1671183662529,
Expand Down
20 changes: 12 additions & 8 deletions src/charging-station/AutomaticTransactionGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,9 +333,9 @@ export class AutomaticTransactionGenerator {
const connectorStatus = this.chargingStation.getConnectorStatus(connectorId)
if (connectorStatus?.transactionStarted === true) {
logger.info(
`${this.logPrefix(
connectorId
)} entered in transaction loop while a transaction ${connectorStatus.transactionId} is already started on connector ${connectorId}`
`${this.logPrefix(connectorId)} entered in transaction loop while a transaction ${
connectorStatus.transactionId
} is already started on connector ${connectorId}`
)
return false
}
Expand Down Expand Up @@ -378,9 +378,9 @@ export class AutomaticTransactionGenerator {
while (connectorStatus?.transactionStarted === true) {
if (!logged) {
logger.info(
`${this.logPrefix(
connectorId
)} transaction loop waiting for started transaction ${connectorStatus.transactionId} on connector ${connectorId} to be stopped`
`${this.logPrefix(connectorId)} transaction loop waiting for started transaction ${
connectorStatus.transactionId
} on connector ${connectorId} to be stopped`
)
logged = true
}
Expand Down Expand Up @@ -416,7 +416,9 @@ export class AutomaticTransactionGenerator {
)
} else if (this.chargingStation.getAutomaticTransactionGeneratorStatuses() != null) {
logger.warn(
`${this.logPrefix(connectorId)} no status found for connector #${connectorId} in charging station configuration file. New status will be created`
`${this.logPrefix(
connectorId
)} no status found for connector #${connectorId} in charging station configuration file. New status will be created`
)
}
if (connectorStatus != null) {
Expand Down Expand Up @@ -507,7 +509,9 @@ export class AutomaticTransactionGenerator {
startResponse = await this.chargingStation.ocppRequestService.requestHandler<
Partial<StartTransactionRequest>,
StartTransactionResponse
>(this.chargingStation, RequestCommand.START_TRANSACTION, { connectorId })
>(this.chargingStation, RequestCommand.START_TRANSACTION, {
connectorId
})
this.handleStartTransactionResponse(connectorId, startResponse)
PerformanceStatistics.endMeasure(measureId, beginId)
return startResponse
Expand Down
28 changes: 21 additions & 7 deletions src/charging-station/Bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,13 @@ export class Bootstrap extends EventEmitter {
)
console.info(
chalk.green(
`Charging stations simulator ${
this.version
} started with ${this.numberOfConfiguredChargingStations} configured and ${this.numberOfProvisionedChargingStations} provisioned charging station(s) from ${this.numberOfChargingStationTemplates} charging station template(s) and ${
`Charging stations simulator ${this.version} started with ${
this.numberOfConfiguredChargingStations
} configured and ${
this.numberOfProvisionedChargingStations
} provisioned charging station(s) from ${
this.numberOfChargingStationTemplates
} charging station template(s) and ${
Configuration.workerDynamicPoolInUse() ? `${workerConfiguration.poolMinSize}/` : ''
}${this.workerImplementation?.size}${
Configuration.workerPoolInUse() ? `/${workerConfiguration.poolMaxSize}` : ''
Expand Down Expand Up @@ -373,7 +377,9 @@ export class Bootstrap extends EventEmitter {
poolOptions: {
messageHandler: this.messageHandler.bind(this) as MessageHandler<Worker>,
...(workerConfiguration.resourceLimits != null && {
workerOptions: { resourceLimits: workerConfiguration.resourceLimits }
workerOptions: {
resourceLimits: workerConfiguration.resourceLimits
}
})
}
}
Expand Down Expand Up @@ -418,7 +424,11 @@ export class Bootstrap extends EventEmitter {
break
default:
throw new BaseError(
`Unknown charging station worker message event: '${event}' received with data: ${JSON.stringify(data, undefined, 2)}`
`Unknown charging station worker message event: '${event}' received with data: ${JSON.stringify(
data,
undefined,
2
)}`
)
}
} catch (error) {
Expand All @@ -436,7 +446,9 @@ export class Bootstrap extends EventEmitter {
data.stationInfo.chargingStationId
} (hashId: ${data.stationInfo.hashId}) added (${
this.numberOfAddedChargingStations
} added from ${this.numberOfConfiguredChargingStations} configured and ${this.numberOfProvisionedChargingStations} provisioned charging station(s))`
} added from ${this.numberOfConfiguredChargingStations} configured and ${
this.numberOfProvisionedChargingStations
} provisioned charging station(s))`
)
}

Expand All @@ -451,7 +463,9 @@ export class Bootstrap extends EventEmitter {
data.stationInfo.chargingStationId
} (hashId: ${data.stationInfo.hashId}) deleted (${
this.numberOfAddedChargingStations
} added from ${this.numberOfConfiguredChargingStations} configured and ${this.numberOfProvisionedChargingStations} provisioned charging station(s))`
} added from ${this.numberOfConfiguredChargingStations} configured and ${
this.numberOfProvisionedChargingStations
} provisioned charging station(s))`
)
}

Expand Down
24 changes: 18 additions & 6 deletions src/charging-station/ChargingStation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,9 @@ export class ChargingStation extends EventEmitter {
: this.configuredSupervisionUrl.href
}`
return new URL(
`${wsConnectionBaseUrlStr}${!wsConnectionBaseUrlStr.endsWith('/') ? '/' : ''}${this.stationInfo?.chargingStationId}`
`${wsConnectionBaseUrlStr}${
!wsConnectionBaseUrlStr.endsWith('/') ? '/' : ''
}${this.stationInfo?.chargingStationId}`
)
}

Expand Down Expand Up @@ -1362,7 +1364,9 @@ export class ChargingStation extends EventEmitter {
addConfigurationKey(this, StandardParametersKey.HeartbeatInterval, '0')
}
if (getConfigurationKey(this, StandardParametersKey.HeartBeatInterval) == null) {
addConfigurationKey(this, StandardParametersKey.HeartBeatInterval, '0', { visible: false })
addConfigurationKey(this, StandardParametersKey.HeartBeatInterval, '0', {
visible: false
})
}
if (
this.stationInfo?.supervisionUrlOcppConfiguration === true &&
Expand All @@ -1380,7 +1384,9 @@ export class ChargingStation extends EventEmitter {
isNotEmptyString(this.stationInfo.supervisionUrlOcppKey) &&
getConfigurationKey(this, this.stationInfo.supervisionUrlOcppKey) != null
) {
deleteConfigurationKey(this, this.stationInfo.supervisionUrlOcppKey, { save: false })
deleteConfigurationKey(this, this.stationInfo.supervisionUrlOcppKey, {
save: false
})
}
if (
isNotEmptyString(this.stationInfo?.amperageLimitationOcppKey) &&
Expand Down Expand Up @@ -1739,7 +1745,9 @@ export class ChargingStation extends EventEmitter {
...(this.connectors.size > 0 && {
connectorsStatus: configurationData.connectorsStatus
}),
...(this.evses.size > 0 && { evsesStatus: configurationData.evsesStatus })
...(this.evses.size > 0 && {
evsesStatus: configurationData.evsesStatus
})
} satisfies ChargingStationConfiguration)
)
.digest('hex')
Expand Down Expand Up @@ -1816,7 +1824,9 @@ export class ChargingStation extends EventEmitter {
if (this.isWebSocketConnectionOpened()) {
this.emit(ChargingStationEvents.updated)
logger.info(
`${this.logPrefix()} Connection to OCPP server through ${this.wsConnectionUrl.href} succeeded`
`${this.logPrefix()} Connection to OCPP server through ${
this.wsConnectionUrl.href
} succeeded`
)
let registrationRetryCount = 0
if (!this.isRegistered()) {
Expand Down Expand Up @@ -2075,7 +2085,9 @@ export class ChargingStation extends EventEmitter {
// eslint-disable-next-line @typescript-eslint/no-base-to-string
}' message '${data.toString()}'${
this.requests.has(messageId)
? ` matching cached request '${JSON.stringify(this.getCachedRequest(messageType, messageId))}'`
? ` matching cached request '${JSON.stringify(
this.getCachedRequest(messageType, messageId)
)}'`
: ''
} processing error:`,
error
Expand Down
11 changes: 9 additions & 2 deletions src/charging-station/Helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,11 @@ export const checkConnectorsConfiguration = (
)
stationTemplate.randomConnectors = true
}
return { configuredMaxConnectors, templateMaxConnectors, templateMaxAvailableConnectors }
return {
configuredMaxConnectors,
templateMaxConnectors,
templateMaxAvailableConnectors
}
}

export const checkStationInfoConnectorStatus = (
Expand Down Expand Up @@ -524,7 +528,10 @@ export const createSerialNumber = (
randomSerialNumber?: boolean
}
): void => {
params = { ...{ randomSerialNumberUpperCase: true, randomSerialNumber: true }, ...params }
params = {
...{ randomSerialNumberUpperCase: true, randomSerialNumber: true },
...params
}
const serialNumberSuffix =
params.randomSerialNumber === true
? getRandomSerialNumberSuffix({
Expand Down
Loading

0 comments on commit 48847bc

Please sign in to comment.