@forzalabs/remora 1.0.21 → 1.0.22
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/Constants.js +1 -1
- package/actions/debug.js +1 -1
- package/definitions/ProcessENV.js +167 -0
- package/engines/Environment.js +3 -3
- package/engines/ProcessENVManager.js +56 -27
- package/index.js +96 -91
- package/package.json +1 -1
- package/workers/ExecutorWorker.js +2 -0
package/Constants.js
CHANGED
package/actions/debug.js
CHANGED
|
@@ -21,7 +21,7 @@ const compile_1 = require("./compile");
|
|
|
21
21
|
const debug = (options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
22
22
|
void options;
|
|
23
23
|
try {
|
|
24
|
-
(0, compile_1.compile)();
|
|
24
|
+
yield (0, compile_1.compile)();
|
|
25
25
|
console.log('\n');
|
|
26
26
|
const spinner = (0, ora_1.default)({ text: '⏳ Checking producers connections...', color: 'blue' }).start();
|
|
27
27
|
const producers = Environment_1.default._env.producers;
|
|
@@ -1,2 +1,169 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.REMORA_ENV_VARIABLES = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* All the environment variables required for operativity of remora
|
|
6
|
+
*/
|
|
7
|
+
exports.REMORA_ENV_VARIABLES = [
|
|
8
|
+
{
|
|
9
|
+
name: 'REMORA_LICENCE_KEY',
|
|
10
|
+
apps: [
|
|
11
|
+
{ name: 'cli', required: true },
|
|
12
|
+
{ name: 'worker', required: true },
|
|
13
|
+
{ name: 'backend', required: true }
|
|
14
|
+
],
|
|
15
|
+
description: 'The licence key to activate this remora licence. If you don\'t have it contact your tech support or reach out to Forza Labs.'
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
name: 'REMORA_APP',
|
|
19
|
+
apps: [
|
|
20
|
+
{ name: 'cli', required: true },
|
|
21
|
+
{ name: 'worker', required: true },
|
|
22
|
+
{ name: 'backend', required: true }
|
|
23
|
+
],
|
|
24
|
+
description: 'The Remora app name (cli, worker, backend, frontend).'
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
name: 'REMORA_WORKER_HOST',
|
|
28
|
+
apps: [
|
|
29
|
+
{ name: 'backend', required: true },
|
|
30
|
+
{ name: 'cli', required: false }
|
|
31
|
+
],
|
|
32
|
+
description: 'The host address for the deployed Remora worker instance.'
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
name: 'ADMIN_JWT_SECRET_FILE',
|
|
36
|
+
apps: [
|
|
37
|
+
{ name: 'worker', required: true },
|
|
38
|
+
{ name: 'backend', required: true }
|
|
39
|
+
],
|
|
40
|
+
description: 'The secret used to verify the JWT from the admin user of the Remora WebApp. Used for all admin operations.'
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: 'JWT_SECRET_FILE',
|
|
44
|
+
apps: [
|
|
45
|
+
{ name: 'worker', required: true },
|
|
46
|
+
{ name: 'backend', required: true }
|
|
47
|
+
],
|
|
48
|
+
description: ''
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
name: 'ROOT_TEMP_PASSWORD_FILE',
|
|
52
|
+
apps: [
|
|
53
|
+
{ name: 'worker', required: true },
|
|
54
|
+
{ name: 'backend', required: true }
|
|
55
|
+
],
|
|
56
|
+
description: ''
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
name: 'REMORA_WORKERS_PATH',
|
|
60
|
+
apps: [
|
|
61
|
+
{ name: 'worker', required: false },
|
|
62
|
+
{ name: 'cli', required: false }
|
|
63
|
+
],
|
|
64
|
+
description: 'A valid path that overrides the default path for the multi-thread workers for the Remora engine.'
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
name: 'REMORA_KEY_SECRET_FILE',
|
|
68
|
+
apps: [
|
|
69
|
+
{ name: 'worker', required: true },
|
|
70
|
+
{ name: 'cli', required: false }
|
|
71
|
+
],
|
|
72
|
+
description: 'The CLI '
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
name: 'ADMIN_JWT_SECRET_FILE',
|
|
76
|
+
apps: [
|
|
77
|
+
{ name: 'worker', required: true }
|
|
78
|
+
],
|
|
79
|
+
description: 'The secret used to verify the JWT from the admin user of the Remora WebApp. Used for all admin operations.'
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
name: 'ADMIN_JWT_SECRET_FILE',
|
|
83
|
+
apps: [
|
|
84
|
+
{ name: 'worker', required: true }
|
|
85
|
+
],
|
|
86
|
+
description: 'The secret used to verify the JWT from the admin user of the Remora WebApp. Used for all admin operations.'
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
name: 'MONGO_URI',
|
|
90
|
+
apps: [
|
|
91
|
+
{ name: 'worker', required: true },
|
|
92
|
+
{ name: 'backend', required: true }
|
|
93
|
+
],
|
|
94
|
+
description: 'The databse uri (Mongo compatible) where to store Remora telemetry.'
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
name: 'REMORA_SALT',
|
|
98
|
+
apps: [
|
|
99
|
+
{ name: 'worker', required: false },
|
|
100
|
+
{ name: 'cli', required: false }
|
|
101
|
+
],
|
|
102
|
+
description: 'A secret salt value used when masking data.'
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
name: 'OPENAI_API_KEY',
|
|
106
|
+
apps: [
|
|
107
|
+
{ name: 'worker', required: false },
|
|
108
|
+
{ name: 'cli', required: false }
|
|
109
|
+
],
|
|
110
|
+
description: ''
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
name: 'AWS_DEFAULT_REGION',
|
|
114
|
+
apps: [
|
|
115
|
+
{ name: 'worker', required: false },
|
|
116
|
+
{ name: 'cli', required: false }
|
|
117
|
+
],
|
|
118
|
+
description: ''
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
name: 'AWS_ACCOUNT_ID',
|
|
122
|
+
apps: [
|
|
123
|
+
{ name: 'worker', required: false },
|
|
124
|
+
{ name: 'cli', required: false }
|
|
125
|
+
],
|
|
126
|
+
description: ''
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
name: 'AWS_ACCESS_KEY_ID',
|
|
130
|
+
apps: [
|
|
131
|
+
{ name: 'worker', required: false },
|
|
132
|
+
{ name: 'cli', required: false }
|
|
133
|
+
],
|
|
134
|
+
description: ''
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
name: 'AWS_SECRET_ACCESS_KEY',
|
|
138
|
+
apps: [
|
|
139
|
+
{ name: 'worker', required: false },
|
|
140
|
+
{ name: 'cli', required: false }
|
|
141
|
+
],
|
|
142
|
+
description: ''
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
name: 'AWS_SESSION_TOKEN',
|
|
146
|
+
apps: [
|
|
147
|
+
{ name: 'worker', required: false },
|
|
148
|
+
{ name: 'cli', required: false }
|
|
149
|
+
],
|
|
150
|
+
description: ''
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
name: 'DELTA_TOKEN',
|
|
154
|
+
apps: [
|
|
155
|
+
{ name: 'worker', required: false },
|
|
156
|
+
{ name: 'cli', required: false }
|
|
157
|
+
],
|
|
158
|
+
description: ''
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
name: 'NODE_ENV',
|
|
162
|
+
apps: [
|
|
163
|
+
{ name: 'worker', required: false },
|
|
164
|
+
{ name: 'cli', required: false },
|
|
165
|
+
{ name: 'backend', required: false }
|
|
166
|
+
],
|
|
167
|
+
description: ''
|
|
168
|
+
}
|
|
169
|
+
];
|
package/engines/Environment.js
CHANGED
|
@@ -13,9 +13,6 @@ const Logger_1 = __importDefault(require("../helper/Logger"));
|
|
|
13
13
|
class EnvironmentClass {
|
|
14
14
|
constructor() {
|
|
15
15
|
this._env = null;
|
|
16
|
-
this.init = (env) => {
|
|
17
|
-
this._env = env;
|
|
18
|
-
};
|
|
19
16
|
this.load = (remoraPath) => {
|
|
20
17
|
const envPath = path_1.default.join(remoraPath, 'remora');
|
|
21
18
|
// Read and parse project.json
|
|
@@ -100,6 +97,9 @@ class EnvironmentClass {
|
|
|
100
97
|
sqlLibrary: [] // TODO: Add SQL library loading if needed
|
|
101
98
|
});
|
|
102
99
|
};
|
|
100
|
+
this.init = (env) => {
|
|
101
|
+
this._env = env;
|
|
102
|
+
};
|
|
103
103
|
this.get = (setting) => {
|
|
104
104
|
return this._env.settings.get(setting);
|
|
105
105
|
};
|
|
@@ -32,6 +32,15 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
32
32
|
return result;
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
+
});
|
|
43
|
+
};
|
|
35
44
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
45
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
46
|
};
|
|
@@ -39,42 +48,62 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
39
48
|
const fs = __importStar(require("fs"));
|
|
40
49
|
const process_1 = __importDefault(require("process"));
|
|
41
50
|
const Affirm_1 = __importDefault(require("../core/Affirm"));
|
|
51
|
+
const ProcessENV_1 = require("../definitions/ProcessENV");
|
|
52
|
+
const Algo_1 = __importDefault(require("../core/Algo"));
|
|
53
|
+
const Logger_1 = __importDefault(require("../helper/Logger"));
|
|
42
54
|
class ProcessENVManagerClass {
|
|
43
55
|
constructor() {
|
|
56
|
+
this._USER_ACCEPTED_ENV_VARIABLE_BEGINNING = 'REMORA';
|
|
44
57
|
/**
|
|
45
|
-
*
|
|
46
|
-
|
|
47
|
-
this.FOUNDAMENTAL_ENVIRONMENT_VARIABLES = ['REMORA_LICENCE_KEY'];
|
|
48
|
-
/**
|
|
49
|
-
* All the variables that are not foundamental for the operativity of remora
|
|
58
|
+
* Load the environment variables in the manager.
|
|
59
|
+
* WARN: call this after the environment has been setup (after the process.env variables have been loaded).
|
|
50
60
|
*/
|
|
51
|
-
this.
|
|
61
|
+
this.init = () => __awaiter(this, void 0, void 0, function* () {
|
|
62
|
+
const appName = process_1.default.env.REMORA_APP;
|
|
63
|
+
(0, Affirm_1.default)(appName, `Missing REMORA_APP in the environment variables. Add the environment variable REMORA_APP=<cli | worker | backend | frontend> depending on the app you are running.`);
|
|
64
|
+
this._loadedVariables = {};
|
|
65
|
+
for (const variable of ProcessENV_1.REMORA_ENV_VARIABLES) {
|
|
66
|
+
if (variable.apps.some(x => x.name === appName)) {
|
|
67
|
+
const { apps, name } = variable;
|
|
68
|
+
const app = apps.find(x => x.name === appName);
|
|
69
|
+
const value = this._loadEnvVarValue(name);
|
|
70
|
+
if (app.required && !Algo_1.default.hasVal(value))
|
|
71
|
+
throw new Error(`Missing required Remora environment variable: ${variable}`);
|
|
72
|
+
this._loadedVariables[name] = value;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
const userRemoraEnvVariables = Object.keys(process_1.default.env)
|
|
76
|
+
.filter(x => x.startsWith(this._USER_ACCEPTED_ENV_VARIABLE_BEGINNING))
|
|
77
|
+
.map(x => ({ name: x, value: process_1.default.env[x] }));
|
|
78
|
+
for (const envVar of userRemoraEnvVariables) {
|
|
79
|
+
const varName = envVar.name;
|
|
80
|
+
this._loadedVariables[varName] = this._loadEnvVarValue(varName);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
this._loadEnvVarValue = (varName) => {
|
|
84
|
+
if (process_1.default.env[varName] && process_1.default.env[varName].includes('run/secrets/'))
|
|
85
|
+
return fs.readFileSync(process_1.default.env[varName], 'utf-8');
|
|
86
|
+
else
|
|
87
|
+
return process_1.default.env[varName];
|
|
88
|
+
};
|
|
52
89
|
/**
|
|
53
|
-
*
|
|
54
|
-
* @param variable
|
|
55
|
-
* @returns
|
|
90
|
+
* Get the value of an environment variable and give an error/warn if not implemented.
|
|
91
|
+
* @param variable The name of the environment variable desired (usually all UPPER_CASE)
|
|
92
|
+
* @returns The value of environment variable
|
|
56
93
|
*/
|
|
57
94
|
this.getEnvVariable = (variable) => {
|
|
58
|
-
(0, Affirm_1.default)(variable, `Cannot read an undefined variable`);
|
|
59
|
-
if (!
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
if (!process_1.default.env[variable] && this.FOUNDAMENTAL_ENVIRONMENT_VARIABLES.includes(variable)) {
|
|
63
|
-
throw new Error(`Missing necessary property for ${variable}`);
|
|
64
|
-
}
|
|
65
|
-
else if (!process_1.default.env[variable]) {
|
|
66
|
-
// give a warn if it's not neccessary for the operativity of remora
|
|
67
|
-
console.warn(`Missing property for ${variable}`);
|
|
95
|
+
(0, Affirm_1.default)(variable, `Cannot read an undefined env variable`);
|
|
96
|
+
if (!Algo_1.default.hasVal(this._loadedVariables)) {
|
|
97
|
+
Logger_1.default.log(`Trying to read an environment variable (${variable}) before initializing the env manager.`);
|
|
68
98
|
return null;
|
|
69
99
|
}
|
|
70
|
-
|
|
71
|
-
if (
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
100
|
+
const result = this._loadedVariables[variable];
|
|
101
|
+
if (Algo_1.default.hasVal(result)) {
|
|
102
|
+
return result;
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
console.warn(`Trying to read an environment variable that was not found: ${variable}`);
|
|
106
|
+
return undefined;
|
|
78
107
|
}
|
|
79
108
|
};
|
|
80
109
|
}
|
package/index.js
CHANGED
|
@@ -22,97 +22,102 @@ const sample_1 = require("./actions/sample");
|
|
|
22
22
|
const mock_1 = require("./actions/mock");
|
|
23
23
|
const ProcessENVManager_1 = __importDefault(require("./engines/ProcessENVManager"));
|
|
24
24
|
dotenv_1.default.configDotenv();
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
// Runtime check on heap size to warn user of insufficent runtime resources
|
|
34
|
-
const { heapSizeMB } = Runtime_1.default.getHeap();
|
|
35
|
-
if (heapSizeMB < Constants_1.default.defaults.MIN_RUNTIME_HEAP_MB)
|
|
36
|
-
console.warn(`Remora is running with ${heapSizeMB}MB of runtime heap, which is below the bare minimum of ${Constants_1.default.defaults.MIN_RUNTIME_HEAP_MB}MB (Recommended: ${Constants_1.default.defaults.RECOMMENDED_RUNTIME_HEAP_MB}MB).`);
|
|
37
|
-
else if (heapSizeMB < Constants_1.default.defaults.RECOMMENDED_RUNTIME_HEAP_MB)
|
|
38
|
-
console.warn(`Remora is running with ${heapSizeMB} MB of runtime heap, which is below the recommended of ${Constants_1.default.defaults.RECOMMENDED_RUNTIME_HEAP_MB} MB.`);
|
|
39
|
-
// Initialize all commands
|
|
40
|
-
program
|
|
41
|
-
.version(Constants_1.default.cliVersion + '', '-v, --version', 'Display the version of the CLI')
|
|
42
|
-
.description('CLI tool for setting up and managing Data-Remora');
|
|
43
|
-
program
|
|
44
|
-
.command('version')
|
|
45
|
-
.description('Display the version of the CLI')
|
|
46
|
-
.action(() => {
|
|
47
|
-
const packageJson = require('../package.json');
|
|
48
|
-
console.log(`Data-Remora CLI version: ${packageJson.version}`);
|
|
49
|
-
});
|
|
50
|
-
program
|
|
51
|
-
.command('init')
|
|
52
|
-
.description('Initialize the application and set up configuration')
|
|
53
|
-
.action(init_1.init);
|
|
54
|
-
program
|
|
55
|
-
.command('compile')
|
|
56
|
-
.description('Compile the config and check for errors')
|
|
57
|
-
.action(compile_1.compile);
|
|
58
|
-
program
|
|
59
|
-
.command('debug')
|
|
60
|
-
.description('Check the connection with sources and producers')
|
|
61
|
-
.action(debug_1.debug);
|
|
62
|
-
program
|
|
63
|
-
.command('deploy')
|
|
64
|
-
.description('Deploy the application to the specified environment')
|
|
65
|
-
.option('-e, --env <environment>', 'Target environment (staging, production)', 'staging')
|
|
66
|
-
.option('--skip-tests', 'Skip running tests before deployment')
|
|
67
|
-
.option('--build-only', 'Build without deploying')
|
|
68
|
-
.action(deploy_1.deploy);
|
|
69
|
-
program
|
|
70
|
-
.command('run [name]')
|
|
71
|
-
.description('Execute consumers. Optionally specify a single consumer name or use --project to run all consumers in a project.')
|
|
72
|
-
.option('-p, --project <name>', 'Run all consumers belonging to the specified project')
|
|
73
|
-
.action((name, options) => (0, run_1.run)(name, options));
|
|
74
|
-
program
|
|
75
|
-
.command('discover')
|
|
76
|
-
.description('Discover the data shape of a producer and automatically create the resource for it.')
|
|
77
|
-
.argument('<producer>', 'The producer to discover')
|
|
78
|
-
.action(discover_1.discover);
|
|
79
|
-
program
|
|
80
|
-
.command('create-producer <name>')
|
|
81
|
-
.description('Create a new producer configuration with default settings')
|
|
82
|
-
.action(create_producer_1.create_producer);
|
|
83
|
-
program
|
|
84
|
-
.command('automap')
|
|
85
|
-
.description('Automatically map a producer to consumers using specified schemas.')
|
|
86
|
-
.argument('<producer>', 'The producer to analyze')
|
|
87
|
-
.argument('<schemas...>', 'One or more schema names to map against')
|
|
88
|
-
.action(automap_1.automap);
|
|
89
|
-
program
|
|
90
|
-
.command('create-consumer <name>')
|
|
91
|
-
.description('Create a new consumer configuration with default settings')
|
|
92
|
-
.option('-p, --producer <name>', 'Producer to create a one-to-one mapping from')
|
|
93
|
-
.action((name, options) => (0, create_consumer_1.create_consumer)(name, options.producer));
|
|
94
|
-
program
|
|
95
|
-
.command('sample <name>')
|
|
96
|
-
.description('Sample data from a producer or consumer and display it in a formatted table')
|
|
97
|
-
.option('-s, --size <number>', 'Number of sample rows to display (default: 10)', '10')
|
|
98
|
-
.action((name, options) => {
|
|
99
|
-
const sampleSize = parseInt(options.size, 10);
|
|
100
|
-
if (isNaN(sampleSize) || sampleSize <= 0) {
|
|
101
|
-
console.error('Sample size must be a positive number');
|
|
102
|
-
process.exit(1);
|
|
103
|
-
}
|
|
104
|
-
(0, sample_1.sample)(name, sampleSize);
|
|
105
|
-
});
|
|
106
|
-
program
|
|
107
|
-
.command('mock <producer>')
|
|
108
|
-
.description('Generate mock data for a producer based on its dimensions')
|
|
109
|
-
.argument('<records>', 'Number of mock records to generate')
|
|
110
|
-
.action((producer, records) => {
|
|
111
|
-
const recordCount = parseInt(records, 10);
|
|
112
|
-
if (isNaN(recordCount) || recordCount <= 0) {
|
|
113
|
-
console.error('Record count must be a positive number');
|
|
25
|
+
ProcessENVManager_1.default.init()
|
|
26
|
+
.then(() => {
|
|
27
|
+
// Validate the remora licence
|
|
28
|
+
const remoraLicenceKey = ProcessENVManager_1.default.getEnvVariable('REMORA_LICENCE_KEY');
|
|
29
|
+
const check = LicenceManager_1.default.validate(remoraLicenceKey);
|
|
30
|
+
if (!check.valid) {
|
|
31
|
+
console.error(`Invalid Remora licence key, the product is not active: remember to set "REMORA_LICENCE_KEY" environment variable.`);
|
|
114
32
|
process.exit(1);
|
|
115
33
|
}
|
|
116
|
-
|
|
34
|
+
// Runtime check on heap size to warn user of insufficent runtime resources
|
|
35
|
+
const { heapSizeMB } = Runtime_1.default.getHeap();
|
|
36
|
+
if (heapSizeMB < Constants_1.default.defaults.MIN_RUNTIME_HEAP_MB)
|
|
37
|
+
console.warn(`Remora is running with ${heapSizeMB}MB of runtime heap, which is below the bare minimum of ${Constants_1.default.defaults.MIN_RUNTIME_HEAP_MB}MB (Recommended: ${Constants_1.default.defaults.RECOMMENDED_RUNTIME_HEAP_MB}MB).`);
|
|
38
|
+
else if (heapSizeMB < Constants_1.default.defaults.RECOMMENDED_RUNTIME_HEAP_MB)
|
|
39
|
+
console.warn(`Remora is running with ${heapSizeMB} MB of runtime heap, which is below the recommended of ${Constants_1.default.defaults.RECOMMENDED_RUNTIME_HEAP_MB} MB.`);
|
|
40
|
+
})
|
|
41
|
+
.then(() => {
|
|
42
|
+
// Initialize all commands
|
|
43
|
+
const program = new commander_1.Command();
|
|
44
|
+
program
|
|
45
|
+
.version(Constants_1.default.cliVersion + '', '-v, --version', 'Display the version of the CLI')
|
|
46
|
+
.description('CLI tool for setting up and managing Data-Remora');
|
|
47
|
+
program
|
|
48
|
+
.command('version')
|
|
49
|
+
.description('Display the version of the CLI')
|
|
50
|
+
.action(() => {
|
|
51
|
+
const packageJson = require('../package.json');
|
|
52
|
+
console.log(`Data-Remora CLI version: ${packageJson.version}`);
|
|
53
|
+
});
|
|
54
|
+
program
|
|
55
|
+
.command('init')
|
|
56
|
+
.description('Initialize the application and set up configuration')
|
|
57
|
+
.action(init_1.init);
|
|
58
|
+
program
|
|
59
|
+
.command('compile')
|
|
60
|
+
.description('Compile the config and check for errors')
|
|
61
|
+
.action(compile_1.compile);
|
|
62
|
+
program
|
|
63
|
+
.command('debug')
|
|
64
|
+
.description('Check the connection with sources and producers')
|
|
65
|
+
.action(debug_1.debug);
|
|
66
|
+
program
|
|
67
|
+
.command('deploy')
|
|
68
|
+
.description('Deploy the application to the specified environment')
|
|
69
|
+
.option('-e, --env <environment>', 'Target environment (staging, production)', 'staging')
|
|
70
|
+
.option('--skip-tests', 'Skip running tests before deployment')
|
|
71
|
+
.option('--build-only', 'Build without deploying')
|
|
72
|
+
.action(deploy_1.deploy);
|
|
73
|
+
program
|
|
74
|
+
.command('run [name]')
|
|
75
|
+
.description('Execute consumers. Optionally specify a single consumer name or use --project to run all consumers in a project.')
|
|
76
|
+
.option('-p, --project <name>', 'Run all consumers belonging to the specified project')
|
|
77
|
+
.action((name, options) => (0, run_1.run)(name, options));
|
|
78
|
+
program
|
|
79
|
+
.command('discover')
|
|
80
|
+
.description('Discover the data shape of a producer and automatically create the resource for it.')
|
|
81
|
+
.argument('<producer>', 'The producer to discover')
|
|
82
|
+
.action(discover_1.discover);
|
|
83
|
+
program
|
|
84
|
+
.command('create-producer <name>')
|
|
85
|
+
.description('Create a new producer configuration with default settings')
|
|
86
|
+
.action(create_producer_1.create_producer);
|
|
87
|
+
program
|
|
88
|
+
.command('automap')
|
|
89
|
+
.description('Automatically map a producer to consumers using specified schemas.')
|
|
90
|
+
.argument('<producer>', 'The producer to analyze')
|
|
91
|
+
.argument('<schemas...>', 'One or more schema names to map against')
|
|
92
|
+
.action(automap_1.automap);
|
|
93
|
+
program
|
|
94
|
+
.command('create-consumer <name>')
|
|
95
|
+
.description('Create a new consumer configuration with default settings')
|
|
96
|
+
.option('-p, --producer <name>', 'Producer to create a one-to-one mapping from')
|
|
97
|
+
.action((name, options) => (0, create_consumer_1.create_consumer)(name, options.producer));
|
|
98
|
+
program
|
|
99
|
+
.command('sample <name>')
|
|
100
|
+
.description('Sample data from a producer or consumer and display it in a formatted table')
|
|
101
|
+
.option('-s, --size <number>', 'Number of sample rows to display (default: 10)', '10')
|
|
102
|
+
.action((name, options) => {
|
|
103
|
+
const sampleSize = parseInt(options.size, 10);
|
|
104
|
+
if (isNaN(sampleSize) || sampleSize <= 0) {
|
|
105
|
+
console.error('Sample size must be a positive number');
|
|
106
|
+
process.exit(1);
|
|
107
|
+
}
|
|
108
|
+
(0, sample_1.sample)(name, sampleSize);
|
|
109
|
+
});
|
|
110
|
+
program
|
|
111
|
+
.command('mock <producer>')
|
|
112
|
+
.description('Generate mock data for a producer based on its dimensions')
|
|
113
|
+
.argument('<records>', 'Number of mock records to generate')
|
|
114
|
+
.action((producer, records) => {
|
|
115
|
+
const recordCount = parseInt(records, 10);
|
|
116
|
+
if (isNaN(recordCount) || recordCount <= 0) {
|
|
117
|
+
console.error('Record count must be a positive number');
|
|
118
|
+
process.exit(1);
|
|
119
|
+
}
|
|
120
|
+
(0, mock_1.mock)(producer, recordCount);
|
|
121
|
+
});
|
|
122
|
+
program.parse(process.argv);
|
|
117
123
|
});
|
|
118
|
-
program.parse(process.argv);
|
package/package.json
CHANGED
|
@@ -17,8 +17,10 @@ const dotenv_1 = __importDefault(require("dotenv"));
|
|
|
17
17
|
const Affirm_1 = __importDefault(require("../core/Affirm"));
|
|
18
18
|
const Environment_1 = __importDefault(require("../engines/Environment"));
|
|
19
19
|
const Executor_1 = __importDefault(require("../executors/Executor"));
|
|
20
|
+
const ProcessENVManager_1 = __importDefault(require("../engines/ProcessENVManager"));
|
|
20
21
|
dotenv_1.default.configDotenv();
|
|
21
22
|
const run = (workerData) => __awaiter(void 0, void 0, void 0, function* () {
|
|
23
|
+
yield ProcessENVManager_1.default.init();
|
|
22
24
|
Environment_1.default.load('./');
|
|
23
25
|
try {
|
|
24
26
|
const { workerId, chunk, consumer, producer, prodDimensions, scope, options } = workerData;
|