import chalk from 'chalk';
import semVer from 'semver';
import packageJson from './package.json' assert { type: 'json' };
+import { version, exit } from 'node:process';
/**
* Check if the current node version match the required engines version.
*/
export function checkNodeVersion() {
const enginesNodeVersion = packageJson.engines.node;
- if (semVer.satisfies(process.version, enginesNodeVersion) === false) {
+ if (semVer.satisfies(version, enginesNodeVersion) === false) {
console.error(
chalk.red(
- `Required node version ${enginesNodeVersion} not satisfied with current version ${process.version}.`,
+ `Required node version ${enginesNodeVersion} not satisfied with current version ${version}.`,
),
);
// eslint-disable-next-line n/no-process-exit
- process.exit(1);
+ exit(1);
}
}
-const isCIEnvironment = process.env.CI !== undefined;
-const isCFEnvironment = process.env.VCAP_APPLICATION !== undefined;
+const { env } = require('node:process');
+
+const isCIEnvironment = env.CI !== undefined;
+const isCFEnvironment = env.VCAP_APPLICATION !== undefined;
if (isCFEnvironment === false && isCIEnvironment === false) {
// eslint-disable-next-line n/no-unpublished-require
require('husky').install();
/* eslint-disable n/no-unpublished-import */
import * as os from 'node:os';
+import { env } from 'node:process';
import json from '@rollup/plugin-json';
import terser from '@rollup/plugin-terser';
return availableParallelism;
};
-const isDevelopmentBuild = process.env.BUILD === 'development';
-const isAnalyzeBuild = process.env.ANALYZE;
+const isDevelopmentBuild = env.BUILD === 'development';
+const isAnalyzeBuild = env.ANALYZE;
const sourceMap = !!isDevelopmentBuild;
export default defineConfig({
'node:http2',
'node:path',
'node:perf_hooks',
+ 'node:process',
'node:stream',
'node:url',
'node:util',
-const skipPreinstall = process.env.SKIP_PREINSTALL || process.env.VCAP_APPLICATION !== undefined;
+const { env, exit } = require('node:process');
+
+const skipPreinstall = env.SKIP_PREINSTALL || env.VCAP_APPLICATION !== undefined;
if (skipPreinstall) {
// eslint-disable-next-line n/no-process-exit
- process.exit();
+ exit();
} else {
// eslint-disable-next-line n/no-process-exit
- process.exit(1);
+ exit(1);
}
delete connectorStatus?.lastRunDate;
delete connectorStatus?.stopDate;
delete connectorStatus?.stoppedDate;
+ if (connectorStatus?.start === true) {
+ connectorStatus.start = false;
+ }
return (
connectorStatus ?? {
start: false,
import { EventEmitter } from 'node:events';
import { dirname, extname, join } from 'node:path';
+import { exit } from 'node:process';
import { fileURLToPath } from 'node:url';
import { isMainThread } from 'node:worker_threads';
console.warn(
chalk.yellow("'stationTemplateUrls' not defined or empty in configuration, exiting"),
);
- process.exit(exitCodes.missingChargingStationsConfiguration);
+ exit(exitCodes.missingChargingStationsConfiguration);
}
if (this.numberOfChargingStations === 0) {
console.warn(
chalk.yellow('No charging station template enabled in configuration, exiting'),
);
- process.exit(exitCodes.noChargingStationTemplates);
+ exit(exitCodes.noChargingStationTemplates);
}
this.initializedCounters = true;
}
console.info(`${chalk.green('Graceful shutdown')}`);
this.stop()
.then(() => {
- process.exit(exitCodes.succeeded);
+ exit(exitCodes.succeeded);
})
.catch((error) => {
console.error(chalk.red('Error while shutdowning charging stations simulator: '), error);
- process.exit(exitCodes.gracefulShutdownError);
+ exit(exitCodes.gracefulShutdownError);
});
};
import { createHash, randomBytes } from 'node:crypto';
import type { EventEmitter } from 'node:events';
import { basename, dirname, join } from 'node:path';
+import { env } from 'node:process';
import { fileURLToPath } from 'node:url';
import chalk from 'chalk';
stationTemplate: ChargingStationTemplate,
): string => {
// In case of multiple instances: add instance index to charging station id
- const instanceIndex = process.env.CF_INSTANCE_INDEX ?? 0;
+ const instanceIndex = env.CF_INSTANCE_INDEX ?? 0;
const idSuffix = stationTemplate?.nameSuffix ?? '';
const idStr = `000000000${index.toString()}`;
return stationTemplate?.fixedName
#!/usr/bin/env node
-const fs = require('fs');
+const fs = require('node:fs');
const { MongoClient } = require('mongodb');
#!/usr/bin/env node
-const fs = require('fs');
+const fs = require('node:fs');
const { MongoClient } = require('mongodb');
import { type FSWatcher, readFileSync, watch } from 'node:fs';
import { dirname, join, resolve } from 'node:path';
+import { env } from 'node:process';
import { fileURLToPath } from 'node:url';
import chalk from 'chalk';
}
if (isCFEnvironment() === true) {
delete uiServerConfiguration.options?.host;
- uiServerConfiguration.options!.port = parseInt(process.env.PORT!);
+ uiServerConfiguration.options!.port = parseInt(env.PORT!);
}
return uiServerConfiguration;
}
import { randomBytes, randomInt, randomUUID, webcrypto } from 'node:crypto';
+import { env } from 'node:process';
import { inspect } from 'node:util';
import {
};
export const isCFEnvironment = (): boolean => {
- return !isNullOrUndefined(process.env.VCAP_APPLICATION);
+ return !isNullOrUndefined(env.VCAP_APPLICATION);
};
export const isIterable = <T>(obj: T): boolean => {
+const { env } = require('node:process');
const { defineConfig } = require('eslint-define-config');
module.exports = defineConfig({
},
rules: {
- 'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
- 'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
+ 'no-console': env.NODE_ENV === 'production' ? 'warn' : 'off',
+ 'no-debugger': env.NODE_ENV === 'production' ? 'warn' : 'off',
'vue/require-v-for-key': 'off',
'vue/multi-word-component-names': 'off',
'sort-imports': [
-const http = require('http'),
- path = require('path'),
+const http = require('node:http'),
+ path = require('node:path'),
+ { env } = require('node:process'),
finalhandler = require('finalhandler'),
serveStatic = require('serve-static');
-const isCFEnvironment = process.env.VCAP_APPLICATION !== undefined,
- PORT = isCFEnvironment ? parseInt(process.env.PORT) : 3030,
+const isCFEnvironment = env.VCAP_APPLICATION !== undefined,
+ PORT = isCFEnvironment ? parseInt(env.PORT) : 3030,
uiPath = path.join(__dirname, './dist');
const serve = serveStatic(uiPath);