@autofleet/cli 1.0.17 → 1.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/index.js +34 -1
- package/bin/utils/index.js +10 -1
- package/package.json +1 -1
package/bin/index.js
CHANGED
|
@@ -3,7 +3,9 @@ import yargs from 'yargs';
|
|
|
3
3
|
import { hideBin } from 'yargs/helpers';
|
|
4
4
|
import path from 'path';
|
|
5
5
|
import fs from 'fs';
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
connectAndGetPrefix, parseIps, replaceInFile, terminalCommand,
|
|
8
|
+
} from './utils/index.js';
|
|
7
9
|
|
|
8
10
|
yargs(hideBin(process.argv))
|
|
9
11
|
.command({
|
|
@@ -52,4 +54,35 @@ yargs(hideBin(process.argv))
|
|
|
52
54
|
console.log(`Successfully exposed ${SIMULATION_CLUSTER_FRONT} and added role binding to dispatch simulations`);
|
|
53
55
|
},
|
|
54
56
|
})
|
|
57
|
+
.command({
|
|
58
|
+
command: 'e2e',
|
|
59
|
+
describe: '--branches="ride-ms": "AUT-7070" --e2eBranch=your-e2e-branch',
|
|
60
|
+
async handler(argv) {
|
|
61
|
+
const { branches, e2eBranch = 'master' } = argv;
|
|
62
|
+
const name = branches.replace('{', ' ');
|
|
63
|
+
const formattedName = name.replace(/[^a-z0-9]/gi, '');
|
|
64
|
+
const E2E_SCRIPT_TEMPLATE_FILE_PATH = `${path.resolve()}/bin/utils/e2e.sh`;
|
|
65
|
+
const NEW_E2E_SCRIPT_FILE_PATH = `${path.resolve()}/e2e.sh`;
|
|
66
|
+
replaceInFile({
|
|
67
|
+
newFilePath: NEW_E2E_SCRIPT_FILE_PATH,
|
|
68
|
+
filePath: E2E_SCRIPT_TEMPLATE_FILE_PATH,
|
|
69
|
+
linesToReplace: [
|
|
70
|
+
{
|
|
71
|
+
find: '$E2E_BRANCH_PLACE_HOLDER$',
|
|
72
|
+
replace: e2eBranch,
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
find: '$BRANCHES_PLACE_HOLDER$',
|
|
76
|
+
replace: branches,
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
find: '$NAME_PLACE_HOLDER$',
|
|
80
|
+
replace: formattedName,
|
|
81
|
+
},
|
|
82
|
+
],
|
|
83
|
+
});
|
|
84
|
+
await terminalCommand(`chmod +x ${NEW_E2E_SCRIPT_FILE_PATH} && ${NEW_E2E_SCRIPT_FILE_PATH}`);
|
|
85
|
+
console.log('finished e2e');
|
|
86
|
+
},
|
|
87
|
+
})
|
|
55
88
|
.parse();
|
package/bin/utils/index.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
/* eslint-disable guard-for-in */
|
|
3
|
+
/* eslint-disable no-restricted-syntax */
|
|
2
4
|
import { promisify } from 'util';
|
|
3
5
|
import { exec } from 'child_process';
|
|
4
6
|
import fs from 'fs';
|
|
@@ -18,7 +20,14 @@ export const terminalCommand = async (command) => {
|
|
|
18
20
|
console.log(formattedOutput);
|
|
19
21
|
return formattedOutput;
|
|
20
22
|
};
|
|
21
|
-
const
|
|
23
|
+
export const replaceInFile = ({ newFilePath, filePath, linesToReplace }) => {
|
|
24
|
+
let fileAsString = fs.readFileSync(filePath, 'utf8');
|
|
25
|
+
for (const { find, replace } of linesToReplace) {
|
|
26
|
+
fileAsString = fileAsString.replace(find, replace);
|
|
27
|
+
}
|
|
28
|
+
fs.writeFileSync(newFilePath, fileAsString);
|
|
29
|
+
};
|
|
30
|
+
export const connectToCluster = async (clusterName) => {
|
|
22
31
|
const command = CLUSTER_TO_CMD_MAP[clusterName];
|
|
23
32
|
if (!command) {
|
|
24
33
|
throw new Error(`Cluster name ${clusterName} does not exist!`);
|