zcatalyst-cli 1.15.1 → 1.16.0
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/README.md +11 -0
- package/docs/fn-utils/lib/ensure-java-userconfig.toml +15 -0
- package/lib/commands/init.js +4 -2
- package/lib/commands/project/use.js +4 -0
- package/lib/commands/pull.js +8 -1
- package/lib/deploy/features/functions/index.js +5 -0
- package/lib/fn-utils/lib/common.js +7 -5
- package/lib/fn-utils/lib/ensure-java-userconfig.js +151 -0
- package/lib/fn-utils/lib/java.js +109 -49
- package/lib/pull/features/apig.js +16 -3
- package/lib/pull/features/client.js +16 -3
- package/lib/pull/features/functions/index.js +62 -32
- package/lib/serve/index.js +12 -1
- package/lib/serve/server/lib/java/index.js +7 -2
- package/lib/serve/server/lib/master.js +31 -6
- package/lib/serve/server/lib/python/index.js +6 -2
- package/lib/shell/dependencies/http-functions.js +18 -5
- package/lib/shell/dependencies/invoker/bio/java/JavabioInvoker.java +4 -6
- package/lib/shell/dependencies/invoker/cron/java/JavacronInvoker.java +3 -4
- package/lib/shell/dependencies/invoker/event/java/JavaeventInvoker.java +3 -5
- package/lib/shell/dependencies/invoker/integ/java/JavaintegInvoker.java +2 -2
- package/lib/shell/dependencies/local-function.js +7 -3
- package/lib/shell/prepare/languages/java.js +2 -2
- package/lib/userConfig.js +1 -1
- package/lib/util_modules/constants/lib/apig-rules.js +5 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -80,6 +80,10 @@ Command | Description
|
|
|
80
80
|
**project:reset** | Clear an active project selection and reset to the base project.
|
|
81
81
|
**init** | Initialize a Catalyst project, function, and client resources in the local directory.
|
|
82
82
|
**pull** | Pull resources of your project from the remote console to the local directory.
|
|
83
|
+
**iac:pack** | Creates a import ready zip file.
|
|
84
|
+
**iac:import** | Deploy the iac zip file to console and create a new project with it.
|
|
85
|
+
**iac:export** | Create a zip file out of existing project in console.
|
|
86
|
+
**iac:status** | Displays the status of iac schedule progress.
|
|
83
87
|
**apig:status** | Obtain the current status of API Gateway for your project and the schedule progress.
|
|
84
88
|
**apig:enable** | Enable API Gateway for your project. *In both Console and Local*.
|
|
85
89
|
**apig:disable** | Disable API Gateway for your project. *In both Console and Local*.
|
|
@@ -93,14 +97,21 @@ Command | Description
|
|
|
93
97
|
**functions:shell** | Launch a node shell to test emulated functions of any stack or type, other than Advanced I/O functions.
|
|
94
98
|
**functions:config** | Perform advanced configurations such as memory allocation on a function in your project.
|
|
95
99
|
**functions:delete** | Delete a function from the remote console or the local directory.
|
|
100
|
+
**appsail:add** | Link an already existing AppSail service to Catalyst Project.
|
|
101
|
+
**codelib:install** | Install the code library functionalities into your project.
|
|
96
102
|
**event:generate \| generate:event** | Generate sample payloads from different components or custom event sources to test Event functions.
|
|
97
103
|
**event:generate:integ** | Generate sample payloads for the required integration service to test Integration functions.
|
|
98
104
|
**serve** | Serve Basic I/O and Advanced I/O functions, and the client, to test them locally.
|
|
99
105
|
**deploy** | Deploy the Catalyst project and project resources to the remote console from the local directory.
|
|
100
106
|
**help** | Display the command reference or help for a specific command.
|
|
101
107
|
**run-script \| run** | Run a particular command script defined in *catalyst.json*.
|
|
108
|
+
**config:set** | Set catalyst configuration as a key value pair.
|
|
109
|
+
**config:get** | Get catalyst config value for the specified key.
|
|
110
|
+
**config:delete** | Delete a key from catalyst config.
|
|
111
|
+
**config:list** | List all your catalyst configurations.
|
|
102
112
|
**logout** | Log the CLI out of your Catalyst account.
|
|
103
113
|
|
|
114
|
+
|
|
104
115
|
---
|
|
105
116
|
|
|
106
117
|
## Migration
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
[JAVACONFIG-1]
|
|
2
|
+
context = '''Unable to check the javac version using the given binary path.'''
|
|
3
|
+
aid = '''Please provide a valid java binary path for the config key ${arg[0]} to serve or deploy the function[${arg[1]}].'''
|
|
4
|
+
|
|
5
|
+
[JAVACONFIG-2]
|
|
6
|
+
context = '''Unable to locate the java binary path in your system.'''
|
|
7
|
+
aid = '''Please provide a valid java binary path for the config key ${arg[0]} to serve or deploy the function[${arg[1]}].'''
|
|
8
|
+
|
|
9
|
+
[JAVACONFIG-3]
|
|
10
|
+
context = '''Provided JDK version[${arg[0]}] for the config key ${arg[1]} is lesser than the compatible JDK version[${arg[2]}]'''
|
|
11
|
+
aid = '''Please provide a valid java binary path for the config key ${arg[1]} that is compatible with the JDK version[${arg[2]}] to serve or deploy the function[${arg[3]}].'''
|
|
12
|
+
|
|
13
|
+
[JAVACONFIG-4]
|
|
14
|
+
context = '''Unable to verify the java binary path'''
|
|
15
|
+
aid = '''Please re-check and provide a valid java binary path for the config key ${arg[0]} to serve or deploy the function[${arg[1]}].'''
|
package/lib/commands/init.js
CHANGED
|
@@ -103,7 +103,9 @@ exports.default = new command_1.default('init [feature]')
|
|
|
103
103
|
(0, logger_1.message)('Aborted by user.');
|
|
104
104
|
return;
|
|
105
105
|
}
|
|
106
|
-
|
|
106
|
+
if (feature !== 'project') {
|
|
107
|
+
yield (0, features_1.project)();
|
|
108
|
+
}
|
|
107
109
|
const featureAns = yield prompt_1.default.ask(prompt_1.default.question('features', 'Which are the features you want to setup for this folder?\n This step is optional! Press ' +
|
|
108
110
|
(0, ansi_colors_1.cyan)('<return> ') +
|
|
109
111
|
'to proceed.\n', {
|
|
@@ -130,7 +132,7 @@ exports.default = new command_1.default('init [feature]')
|
|
|
130
132
|
return saveAndComplete(config);
|
|
131
133
|
}
|
|
132
134
|
if (typeof feature === 'string') {
|
|
133
|
-
featureAns.features = feature;
|
|
135
|
+
featureAns.features = [feature];
|
|
134
136
|
}
|
|
135
137
|
runtime_store_1.default.set('context.features', featureAns.features);
|
|
136
138
|
yield (yield Promise.resolve().then(() => __importStar(require('../init')))).default();
|
|
@@ -27,6 +27,10 @@ const makeActive = (currentProjectId, optedProject) => __awaiter(void 0, void 0,
|
|
|
27
27
|
active: true,
|
|
28
28
|
base: js_1.JS.isNull(currentProjectId)
|
|
29
29
|
});
|
|
30
|
+
const optedProjectEnv = optedProject.env_details;
|
|
31
|
+
yield (0, project_2.upsertEnv)(optedProject.id, optedProjectEnv[0], {
|
|
32
|
+
active: true
|
|
33
|
+
});
|
|
30
34
|
(0, logger_1.success)('Successfully made project active');
|
|
31
35
|
});
|
|
32
36
|
exports.default = new command_1.default('project:use [name_or_project_id]')
|
package/lib/commands/pull.js
CHANGED
|
@@ -136,5 +136,12 @@ exports.default = new command_1.default('pull [feature]')
|
|
|
136
136
|
yield config.save();
|
|
137
137
|
(0, logger_1.message)((0, ansi_colors_1.bold)(constants_1.FILENAME.config) + ' file has been successfully updated with feature details.');
|
|
138
138
|
(0, logger_1.info)();
|
|
139
|
-
(
|
|
139
|
+
if ((runtime_store_1.default.get('payload.functions.status') ||
|
|
140
|
+
runtime_store_1.default.get('payload.client.status') ||
|
|
141
|
+
runtime_store_1.default.get('payload.apig.status')) === 1) {
|
|
142
|
+
(0, logger_1.success)('Catalyst pull partially completed!');
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
(0, logger_1.success)('Catalyst pull completed!');
|
|
146
|
+
}
|
|
140
147
|
}));
|
|
@@ -99,6 +99,11 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
99
99
|
})));
|
|
100
100
|
}
|
|
101
101
|
const allTargets = refinedTargets.filter((target) => {
|
|
102
|
+
if (target.compilationWarning) {
|
|
103
|
+
target.compilationWarning.forEach((message) => {
|
|
104
|
+
(0, logger_1.warning)(message);
|
|
105
|
+
});
|
|
106
|
+
}
|
|
102
107
|
if (!target.valid) {
|
|
103
108
|
(0, logger_1.warning)('skipping deploy of target [' + target.name + '] since ' + target.failure_reason);
|
|
104
109
|
}
|
|
@@ -253,11 +253,13 @@ function refineTargets(rawTargets, mapRemoteFn = true) {
|
|
|
253
253
|
}
|
|
254
254
|
exports.refineTargets = refineTargets;
|
|
255
255
|
function refineEnvVariables(vars) {
|
|
256
|
-
return
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
256
|
+
return !vars
|
|
257
|
+
? undefined
|
|
258
|
+
: Object.entries(vars).reduce((envObj, curEntry) => {
|
|
259
|
+
envObj[curEntry[0]] =
|
|
260
|
+
typeof curEntry[1] === 'object' ? JSON.stringify(curEntry[1]) : curEntry[1];
|
|
261
|
+
return envObj;
|
|
262
|
+
}, {});
|
|
261
263
|
}
|
|
262
264
|
function executeHook({ prefix, command }) {
|
|
263
265
|
if ((0, option_1.getOptionValue)('ignoreScripts', false)) {
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.getJavaSpawnCommand = exports.ensureJava = exports.stackVsVersions = void 0;
|
|
16
|
+
const semver_1 = require("semver");
|
|
17
|
+
const error_1 = __importDefault(require("../../error"));
|
|
18
|
+
const runtime_store_1 = __importDefault(require("../../runtime-store"));
|
|
19
|
+
const userConfig_1 = __importDefault(require("../../userConfig"));
|
|
20
|
+
const env_1 = require("../../util_modules/env");
|
|
21
|
+
const shell_1 = require("../../util_modules/shell");
|
|
22
|
+
const java_1 = require("./java");
|
|
23
|
+
exports.stackVsVersions = {
|
|
24
|
+
java8: {
|
|
25
|
+
version: '1.8.0',
|
|
26
|
+
target: '1.8'
|
|
27
|
+
},
|
|
28
|
+
java11: {
|
|
29
|
+
version: '11.0.0',
|
|
30
|
+
target: '11'
|
|
31
|
+
},
|
|
32
|
+
java17: {
|
|
33
|
+
version: '17.0.0',
|
|
34
|
+
target: '17'
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
function ensureJava(target) {
|
|
38
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
const configKey = `${target.stack}.bin`;
|
|
40
|
+
const spawnCommand = userConfig_1.default.get(configKey);
|
|
41
|
+
let usingJavaDefaultPath = false;
|
|
42
|
+
if (!spawnCommand) {
|
|
43
|
+
runtime_store_1.default.set(`context.java.isUsingJavaDefaultPath_${target.stack}`, true);
|
|
44
|
+
usingJavaDefaultPath = true;
|
|
45
|
+
}
|
|
46
|
+
let javacVersion = '';
|
|
47
|
+
const currentStackVersion = exports.stackVsVersions[target.stack].version;
|
|
48
|
+
try {
|
|
49
|
+
const javacSpawnCommand = getJavaSpawnCommand(spawnCommand, 'javac', target.stack);
|
|
50
|
+
javacVersion = yield validateJavaPath(javacSpawnCommand);
|
|
51
|
+
if (!javacVersion) {
|
|
52
|
+
if (spawnCommand) {
|
|
53
|
+
throw new error_1.default(`unable to check the javac version using the given binary path. Kindly re-check. Please provide a valid java binary path for the config key ${target.stack}.bin to serve or deploy the function[${target.name}].`, {
|
|
54
|
+
exit: 0,
|
|
55
|
+
errorId: 'JAVACONFIG-1',
|
|
56
|
+
arg: [
|
|
57
|
+
target.stack,
|
|
58
|
+
target.name,
|
|
59
|
+
`jdk-${exports.stackVsVersions[target.stack]
|
|
60
|
+
.target}`
|
|
61
|
+
]
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
throw new error_1.default(`unable to locate the java binary path in your system. Kindly re-check. Please provide the valid java binary path for the config key ${target.stack}.bin to serve or deploy the function[${target.name}].`, {
|
|
66
|
+
exit: 0,
|
|
67
|
+
errorId: 'JAVACONFIG-2',
|
|
68
|
+
arg: [`${target.stack}.bin`, target.name]
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
catch (_a) {
|
|
74
|
+
throw new error_1.default(`error while validating java binary path. Please provide a valid java binary path for the config key ${target.stack}.bin to serve or deploy the function[${target.name}].`, {
|
|
75
|
+
exit: 0,
|
|
76
|
+
errorId: 'JAVACONFIG-4',
|
|
77
|
+
arg: [`${target.stack}.bin`, target.name]
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
if ((0, semver_1.satisfies)(currentStackVersion, `>${javacVersion}`)) {
|
|
81
|
+
if (usingJavaDefaultPath === false) {
|
|
82
|
+
throw new error_1.default(`provided JDK version[jdk-${javacVersion}] for the config key ${target.stack}.bin is lesser than the compatible JDK version[jdk-${exports.stackVsVersions[target.stack].target}]. Please provide a valid java binary path for the config key ${target.stack}.bin to serve or deploy the function[${target.name}].`, {
|
|
83
|
+
exit: 0,
|
|
84
|
+
skipHelp: true,
|
|
85
|
+
errorId: 'JAVACONFIG-3',
|
|
86
|
+
arg: [
|
|
87
|
+
`jdk-${javacVersion}`,
|
|
88
|
+
target.stack,
|
|
89
|
+
`jdk-${exports.stackVsVersions[target.stack].target}`,
|
|
90
|
+
target.name
|
|
91
|
+
]
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
throw new error_1.default(`provided JDK version[jdk-${javacVersion}] is lesser than the compatible JDK version[jdk-${exports.stackVsVersions[target.stack].target}]. Please provide a valid java binary path for the config key ${target.stack}.bin to serve or deploy the function[${target.name}].`, {
|
|
95
|
+
exit: 0,
|
|
96
|
+
skipHelp: true,
|
|
97
|
+
errorId: 'JAVACONFIG-3',
|
|
98
|
+
arg: [
|
|
99
|
+
`jdk-${javacVersion}`,
|
|
100
|
+
target.stack,
|
|
101
|
+
`jdk-${exports.stackVsVersions[target.stack].target}`,
|
|
102
|
+
target.name
|
|
103
|
+
]
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
const majorVersion = target.stack === 'java8' ? '' : currentStackVersion.split('.')[0];
|
|
107
|
+
if (!(((0, semver_1.satisfies)(javacVersion, `>=${majorVersion}.0.0`) &&
|
|
108
|
+
(0, semver_1.satisfies)(javacVersion, `<=${majorVersion}.x.x`)) ||
|
|
109
|
+
(target.stack === 'java8' &&
|
|
110
|
+
(0, semver_1.satisfies)(javacVersion, '>=1.8.0') &&
|
|
111
|
+
(0, semver_1.satisfies)(javacVersion, '<=1.8.x')))) {
|
|
112
|
+
const warningMessage = [];
|
|
113
|
+
warningMessage.push(`Warning : Your function[${target.name}] stack is ${target.stack}. But you are using jdk ${javacVersion} to compile source files. Please use jdk ${exports.stackVsVersions[target.stack].target} for better compilation`);
|
|
114
|
+
target.compilationWarning = warningMessage;
|
|
115
|
+
}
|
|
116
|
+
if (!spawnCommand) {
|
|
117
|
+
runtime_store_1.default.set(`context.java.isUsingJavaDefaultPath_${target.stack}`, true);
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
exports.ensureJava = ensureJava;
|
|
122
|
+
function validateJavaPath(spawnCommand) {
|
|
123
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
124
|
+
const spawnOpts = ['-version'];
|
|
125
|
+
const javacVersionChild = (0, shell_1.spawn)(spawnCommand, spawnOpts, {
|
|
126
|
+
cwd: runtime_store_1.default.get('cwd'),
|
|
127
|
+
stdio: 'pipe'
|
|
128
|
+
}).RAW();
|
|
129
|
+
let javacVersionDetails = yield (0, java_1.extractAllData)(javacVersionChild, 'stdout');
|
|
130
|
+
javacVersionDetails =
|
|
131
|
+
javacVersionDetails === ''
|
|
132
|
+
? yield (0, java_1.extractAllData)(javacVersionChild, 'stderr')
|
|
133
|
+
: javacVersionDetails;
|
|
134
|
+
const javacVersion = (0, semver_1.valid)((0, semver_1.coerce)(javacVersionDetails.split(' ')[1]));
|
|
135
|
+
return javacVersion;
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
function getJavaSpawnCommand(spawnCommand, process, stack) {
|
|
139
|
+
const isUsingJavaDefaultPath = runtime_store_1.default.get(`context.java.isUsingJavaDefaultPath_${stack}`);
|
|
140
|
+
if (isUsingJavaDefaultPath === true) {
|
|
141
|
+
return process;
|
|
142
|
+
}
|
|
143
|
+
if (env_1.isWindows) {
|
|
144
|
+
spawnCommand = `"${spawnCommand}\\${process}"`;
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
spawnCommand = `${spawnCommand}/${process}`;
|
|
148
|
+
}
|
|
149
|
+
return spawnCommand;
|
|
150
|
+
}
|
|
151
|
+
exports.getJavaSpawnCommand = getJavaSpawnCommand;
|
package/lib/fn-utils/lib/java.js
CHANGED
|
@@ -12,10 +12,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.getTemplatePath = exports.validate = exports.projectFileValidation = exports.ensureJavaInvoker = exports.compileTarget = exports.normaliseClasspath = exports.rewriteClasspath = exports.isValidClassName = exports.containsKeyWord = exports.classPathSep = void 0;
|
|
15
|
+
exports.getTargetVersion = exports.getTemplatePath = exports.validate = exports.extractAllData = exports.projectFileValidation = exports.ensureJavaInvoker = exports.compileTarget = exports.normaliseClasspath = exports.rewriteClasspath = exports.isValidClassName = exports.containsKeyWord = exports.classPathSep = exports.FN_TYPE = void 0;
|
|
16
16
|
const ansi_colors_1 = require("ansi-colors");
|
|
17
17
|
const path_1 = require("path");
|
|
18
|
-
const semver_1 = require("semver");
|
|
19
18
|
const xml2js_1 = __importDefault(require("xml2js"));
|
|
20
19
|
const error_1 = __importDefault(require("../../error"));
|
|
21
20
|
const runtime_store_1 = __importDefault(require("../../runtime-store"));
|
|
@@ -24,9 +23,13 @@ const constants_1 = require("../../util_modules/constants");
|
|
|
24
23
|
const env_1 = require("../../util_modules/env");
|
|
25
24
|
const fs_1 = require("../../util_modules/fs");
|
|
26
25
|
const js_1 = require("../../util_modules/js");
|
|
27
|
-
const logger_1 = require("../../util_modules/logger");
|
|
28
26
|
const option_1 = require("../../util_modules/option");
|
|
29
27
|
const shell_1 = require("../../util_modules/shell");
|
|
28
|
+
const userConfig_1 = __importDefault(require("../../userConfig"));
|
|
29
|
+
const logger_1 = require("../../util_modules/logger");
|
|
30
|
+
const ensure_java_userconfig_1 = require("./ensure-java-userconfig");
|
|
31
|
+
var constants_2 = require("../../util_modules/constants");
|
|
32
|
+
Object.defineProperty(exports, "FN_TYPE", { enumerable: true, get: function () { return constants_2.FN_TYPE; } });
|
|
30
33
|
const keyWords = [
|
|
31
34
|
'abstract',
|
|
32
35
|
'assert',
|
|
@@ -82,6 +85,10 @@ const keyWords = [
|
|
|
82
85
|
'volatile',
|
|
83
86
|
'while'
|
|
84
87
|
];
|
|
88
|
+
const warningMessages = [
|
|
89
|
+
'warning: [options] bootstrap class path not set in conjunction with -source 8',
|
|
90
|
+
'warning: [options] system modules path not set in conjunction with -source 11'
|
|
91
|
+
];
|
|
85
92
|
exports.classPathSep = env_1.isWindows ? ';' : ':';
|
|
86
93
|
function containsKeyWord(name) {
|
|
87
94
|
return keyWords.some((keyWord) => {
|
|
@@ -200,6 +207,9 @@ function compileTarget(target) {
|
|
|
200
207
|
const outputFolder = (0, path_1.join)(targetSource, constants_1.FOLDERNAME.output);
|
|
201
208
|
const integ = target.integ_config;
|
|
202
209
|
const entries = [(0, path_1.join)(targetSource, ((_a = target.index) === null || _a === void 0 ? void 0 : _a.replace(/\./g, path_1.sep)) + '.java')];
|
|
210
|
+
const configKey = `${target.stack}.bin`;
|
|
211
|
+
const userConfigCmd = userConfig_1.default.get(configKey);
|
|
212
|
+
const spawnCommand = (0, ensure_java_userconfig_1.getJavaSpawnCommand)(userConfigCmd, 'javac', target.stack);
|
|
203
213
|
if (integ && integ.length > 0) {
|
|
204
214
|
integ.forEach((integConf) => {
|
|
205
215
|
const handlers = integConf.handlers;
|
|
@@ -225,18 +235,20 @@ function compileTarget(target) {
|
|
|
225
235
|
return fs_1.ASYNC.copyFile(file.path, (0, path_1.join)(outputFolder, targetPth));
|
|
226
236
|
}));
|
|
227
237
|
}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
238
|
+
const targetVersion = getTargetVersion(target.stack);
|
|
239
|
+
yield Promise.all(entries.map((file) => compileJavaFiles(file, spawnCommand, targetVersion, targetSource, outputFolder)
|
|
240
|
+
.then((result) => {
|
|
241
|
+
const code = result[2];
|
|
242
|
+
if (code === 1) {
|
|
243
|
+
const error = [];
|
|
244
|
+
error === null || error === void 0 ? void 0 : error.push(result[1]);
|
|
245
|
+
target.valid = false;
|
|
246
|
+
target.compilationError = error;
|
|
247
|
+
}
|
|
248
|
+
})
|
|
249
|
+
.catch((error) => {
|
|
250
|
+
target.failure_reason = error.message;
|
|
251
|
+
})));
|
|
240
252
|
const currentCommand = (0, option_1.getCurrentCommand)();
|
|
241
253
|
switch (currentCommand) {
|
|
242
254
|
case 'pull':
|
|
@@ -256,20 +268,84 @@ function compileTarget(target) {
|
|
|
256
268
|
});
|
|
257
269
|
}
|
|
258
270
|
exports.compileTarget = compileTarget;
|
|
259
|
-
function
|
|
271
|
+
function compileJavaFiles(file, spawnCommand, targetVersion, targetSource, outputFolder) {
|
|
272
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
273
|
+
(0, logger_1.info)('Compiling ' + file);
|
|
274
|
+
return new Promise((resolve, reject) => {
|
|
275
|
+
var _a, _b;
|
|
276
|
+
const child = (0, shell_1.spawn)(spawnCommand, [
|
|
277
|
+
'-target',
|
|
278
|
+
targetVersion,
|
|
279
|
+
'-source',
|
|
280
|
+
targetVersion,
|
|
281
|
+
'-cp',
|
|
282
|
+
'*' + module.exports.classPathSep + '.',
|
|
283
|
+
'-g',
|
|
284
|
+
'-Xprefer:source',
|
|
285
|
+
file.replace(targetSource, outputFolder)
|
|
286
|
+
], {
|
|
287
|
+
cwd: outputFolder,
|
|
288
|
+
stdio: 'pipe'
|
|
289
|
+
}).RAW();
|
|
290
|
+
let stdout = '';
|
|
291
|
+
let stderr = '';
|
|
292
|
+
(_a = child.stdout) === null || _a === void 0 ? void 0 : _a.on('data', (data) => {
|
|
293
|
+
stdout += data.toString();
|
|
294
|
+
});
|
|
295
|
+
(_b = child.stderr) === null || _b === void 0 ? void 0 : _b.on('data', (data) => {
|
|
296
|
+
const err = data.toString();
|
|
297
|
+
let newErr = '';
|
|
298
|
+
warningMessages.forEach((element) => {
|
|
299
|
+
if (err.includes(element)) {
|
|
300
|
+
newErr += err.replace(element, '');
|
|
301
|
+
}
|
|
302
|
+
});
|
|
303
|
+
if (!newErr) {
|
|
304
|
+
newErr += err;
|
|
305
|
+
}
|
|
306
|
+
stderr += newErr;
|
|
307
|
+
});
|
|
308
|
+
child.on('error', (error) => {
|
|
309
|
+
reject(error);
|
|
310
|
+
});
|
|
311
|
+
child.on('close', (code) => {
|
|
312
|
+
resolve([stdout, stderr, code]);
|
|
313
|
+
});
|
|
314
|
+
});
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
function ensureJavaInvoker(pth, invoker, target) {
|
|
318
|
+
const configKey = `${target.stack}.bin`;
|
|
319
|
+
const userConfigCmd = userConfig_1.default.get(configKey);
|
|
320
|
+
const spawnCommand = (0, ensure_java_userconfig_1.getJavaSpawnCommand)(userConfigCmd, 'javac', target.stack);
|
|
260
321
|
const classPth = pth + '.class';
|
|
322
|
+
const targetVersion = getTargetVersion(target.stack);
|
|
261
323
|
if (fs_1.SYNC.fileExists(classPth)) {
|
|
262
324
|
return true;
|
|
263
325
|
}
|
|
264
326
|
fs_1.SYNC.ensureDir((0, path_1.dirname)(classPth));
|
|
265
|
-
(0, shell_1.spawn)(
|
|
327
|
+
const child = (0, shell_1.spawn)(spawnCommand, [
|
|
328
|
+
'-target',
|
|
329
|
+
targetVersion,
|
|
330
|
+
'-source',
|
|
331
|
+
targetVersion,
|
|
266
332
|
'-cp',
|
|
267
333
|
(0, path_1.join)('lib', '*') + module.exports.classPathSep + '.',
|
|
268
334
|
'-g',
|
|
269
335
|
'-d',
|
|
270
336
|
(0, path_1.dirname)(classPth),
|
|
271
337
|
(0, path_1.basename)(invoker)
|
|
272
|
-
], { cwd: (0, path_1.dirname)(invoker) }).SYNC();
|
|
338
|
+
], { cwd: (0, path_1.dirname)(invoker), stdio: 'pipe' }).SYNC();
|
|
339
|
+
if (child.status === 1) {
|
|
340
|
+
const errorResponse = [];
|
|
341
|
+
const err = child.stderr.toString();
|
|
342
|
+
warningMessages.forEach((element) => {
|
|
343
|
+
if (err.includes(element)) {
|
|
344
|
+
errorResponse.push(err.replace(element, ''));
|
|
345
|
+
}
|
|
346
|
+
});
|
|
347
|
+
target.compilationError = errorResponse;
|
|
348
|
+
}
|
|
273
349
|
fs_1.SYNC.copyDir((0, path_1.join)((0, path_1.dirname)(invoker), 'lib'), (0, path_1.join)((0, path_1.dirname)(classPth), 'lib'));
|
|
274
350
|
return true;
|
|
275
351
|
}
|
|
@@ -316,34 +392,7 @@ function extractAllData(child, name) {
|
|
|
316
392
|
});
|
|
317
393
|
});
|
|
318
394
|
}
|
|
319
|
-
|
|
320
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
321
|
-
const javacVersionChild = (0, shell_1.spawn)('javac', ['-version'], {
|
|
322
|
-
cwd: runtime_store_1.default.get('cwd'),
|
|
323
|
-
stdio: 'pipe'
|
|
324
|
-
}).RAW();
|
|
325
|
-
let javacVersionDetails = yield extractAllData(javacVersionChild, 'stdout');
|
|
326
|
-
javacVersionDetails =
|
|
327
|
-
javacVersionDetails === ''
|
|
328
|
-
? yield extractAllData(javacVersionChild, 'stderr')
|
|
329
|
-
: javacVersionDetails;
|
|
330
|
-
const javacVersion = (0, semver_1.valid)((0, semver_1.coerce)(javacVersionDetails.split(' ')[1]));
|
|
331
|
-
if (javacVersion === '' || javacVersion === null) {
|
|
332
|
-
throw new error_1.default('Unable to check the javac version', {
|
|
333
|
-
exit: 0,
|
|
334
|
-
errorId: 'JAVA-4',
|
|
335
|
-
arg: [(0, ansi_colors_1.bold)('javac')]
|
|
336
|
-
});
|
|
337
|
-
}
|
|
338
|
-
if ((0, semver_1.gtr)(javacVersion, new semver_1.Range('<1.9', { includePrerelease: true }))) {
|
|
339
|
-
throw new error_1.default('javac version is above the compatible version', {
|
|
340
|
-
exit: 0,
|
|
341
|
-
errorId: 'JAVA-5',
|
|
342
|
-
arg: [(0, ansi_colors_1.bold)('javac'), (0, ansi_colors_1.bold)('1.8.x'), (0, ansi_colors_1.bold)('1.8')]
|
|
343
|
-
});
|
|
344
|
-
}
|
|
345
|
-
});
|
|
346
|
-
}
|
|
395
|
+
exports.extractAllData = extractAllData;
|
|
347
396
|
function validate(targets, idx) {
|
|
348
397
|
var _a;
|
|
349
398
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -377,7 +426,7 @@ function validate(targets, idx) {
|
|
|
377
426
|
}
|
|
378
427
|
yield normaliseClasspath(classpath, libFolder);
|
|
379
428
|
yield projectFileValidation(projectPath, currentTarget);
|
|
380
|
-
yield
|
|
429
|
+
yield (0, ensure_java_userconfig_1.ensureJava)(currentTarget);
|
|
381
430
|
yield compileTarget(currentTarget).catch((err) => {
|
|
382
431
|
throw new error_1.default('there was a compilation error!', {
|
|
383
432
|
exit: 1,
|
|
@@ -386,8 +435,15 @@ function validate(targets, idx) {
|
|
|
386
435
|
skipHelp: !!(0, option_1.getOptionValue)('watch', false)
|
|
387
436
|
});
|
|
388
437
|
});
|
|
389
|
-
currentTarget.valid
|
|
390
|
-
|
|
438
|
+
if (currentTarget.valid === true && !currentTarget.failure_reason) {
|
|
439
|
+
currentTarget.valid = true;
|
|
440
|
+
return validate(targets, ++idx);
|
|
441
|
+
}
|
|
442
|
+
throw new error_1.default('there was a compilation error!', {
|
|
443
|
+
exit: 1,
|
|
444
|
+
errorId: 'JAVA-7',
|
|
445
|
+
skipHelp: !!(0, option_1.getOptionValue)('watch', false)
|
|
446
|
+
});
|
|
391
447
|
}
|
|
392
448
|
catch (err) {
|
|
393
449
|
currentTarget.valid = false;
|
|
@@ -452,3 +508,7 @@ function getTemplatePath(fnType, add) {
|
|
|
452
508
|
}
|
|
453
509
|
}
|
|
454
510
|
exports.getTemplatePath = getTemplatePath;
|
|
511
|
+
function getTargetVersion(stack) {
|
|
512
|
+
return ensure_java_userconfig_1.stackVsVersions[stack].target;
|
|
513
|
+
}
|
|
514
|
+
exports.getTargetVersion = getTargetVersion;
|
|
@@ -15,6 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
const ansi_colors_1 = require("ansi-colors");
|
|
16
16
|
const apig_utils_1 = require("../../apig-utils");
|
|
17
17
|
const endpoints_1 = require("../../endpoints");
|
|
18
|
+
const error_1 = __importDefault(require("../../error"));
|
|
18
19
|
const prompt_1 = __importDefault(require("../../prompt"));
|
|
19
20
|
const runtime_store_1 = __importDefault(require("../../runtime-store"));
|
|
20
21
|
const config_1 = require("../../util_modules/config");
|
|
@@ -61,8 +62,20 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
61
62
|
(0, logger_1.info)('No rules found in remote console');
|
|
62
63
|
return;
|
|
63
64
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
try {
|
|
66
|
+
const fileContent = JSON.stringify(rulesArr, null, 2) + '\n';
|
|
67
|
+
yield fs_1.ASYNC.writeFile(apigDirPath, fileContent);
|
|
68
|
+
yield apig_utils_1.apigUtils.validate();
|
|
69
|
+
}
|
|
70
|
+
catch (err) {
|
|
71
|
+
runtime_store_1.default.set('payload.apig.status', 1);
|
|
72
|
+
if (err instanceof error_1.default) {
|
|
73
|
+
throw new error_1.default(err.message, {
|
|
74
|
+
exit: err.exit,
|
|
75
|
+
errorId: err.errorId
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
throw err;
|
|
79
|
+
}
|
|
67
80
|
runtime_store_1.default.set('payload.apig.source', apigDirPath);
|
|
68
81
|
});
|
|
@@ -16,6 +16,7 @@ const ansi_colors_1 = require("ansi-colors");
|
|
|
16
16
|
const archiver_1 = __importDefault(require("../../archiver"));
|
|
17
17
|
const client_utils_1 = require("../../client-utils");
|
|
18
18
|
const endpoints_1 = require("../../endpoints");
|
|
19
|
+
const error_1 = __importDefault(require("../../error"));
|
|
19
20
|
const prompt_1 = __importDefault(require("../../prompt"));
|
|
20
21
|
const runtime_store_1 = __importDefault(require("../../runtime-store"));
|
|
21
22
|
const config_1 = require("../../util_modules/config");
|
|
@@ -58,9 +59,21 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
58
59
|
type: 'list',
|
|
59
60
|
choices
|
|
60
61
|
}));
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
try {
|
|
63
|
+
const clientZip = (yield webappAPI.download(historyAns.history));
|
|
64
|
+
yield new archiver_1.default().load(clientZip).extract(clientDirPath).finalize();
|
|
65
|
+
yield client_utils_1.clientUtils.validate();
|
|
66
|
+
}
|
|
67
|
+
catch (err) {
|
|
68
|
+
runtime_store_1.default.set('payload.client.status', 1);
|
|
69
|
+
if (err instanceof error_1.default) {
|
|
70
|
+
throw new error_1.default(err.message, {
|
|
71
|
+
exit: err.exit,
|
|
72
|
+
errorId: err.errorId
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
throw err;
|
|
76
|
+
}
|
|
64
77
|
runtime_store_1.default.set('payload.client', runtime_store_1.default.get('context.client'));
|
|
65
78
|
runtime_store_1.default.set('payload.client.source', (0, project_1.resolveProjectPath)(clientDirName));
|
|
66
79
|
});
|
|
@@ -29,6 +29,7 @@ const runtime_1 = __importDefault(require("../../../util_modules/constants/lib/r
|
|
|
29
29
|
const error_1 = __importDefault(require("../../../error"));
|
|
30
30
|
const python_1 = require("../../../fn-utils/lib/python");
|
|
31
31
|
const throbber_1 = __importDefault(require("../../../throbber"));
|
|
32
|
+
const ensure_java_userconfig_1 = require("../../../fn-utils/lib/ensure-java-userconfig");
|
|
32
33
|
function selFnsPrompt(targs, fnDirPath) {
|
|
33
34
|
return __awaiter(this, void 0, void 0, function* () {
|
|
34
35
|
const choicesObj = targs.reduce((accumulator, fn) => {
|
|
@@ -134,54 +135,83 @@ exports.default = (_fns) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
134
135
|
});
|
|
135
136
|
}));
|
|
136
137
|
runtime_store_1.default.set('context.functions.targets', targets);
|
|
138
|
+
let isFnPulled = false;
|
|
139
|
+
let isFnPulledFailed = false;
|
|
137
140
|
targets = yield Promise.all(targets.map((fn) => __awaiter(void 0, void 0, void 0, function* () {
|
|
138
141
|
var _a, _b, _c;
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
(
|
|
142
|
+
try {
|
|
143
|
+
yield fs_1.ASYNC.ensureDir(fn.source);
|
|
144
|
+
const buffer = (yield fnAPI.download(fn.id));
|
|
145
|
+
yield new archiver_1.default().load(buffer).extract((0, path_1.join)(fnDirPath, fn.name)).finalize();
|
|
146
|
+
if ((_a = fn.stack) === null || _a === void 0 ? void 0 : _a.startsWith(runtime_1.default.language.node.value)) {
|
|
147
|
+
yield (0, languages_1.node)(fn);
|
|
148
|
+
}
|
|
149
|
+
else if ((_b = fn.stack) === null || _b === void 0 ? void 0 : _b.startsWith(runtime_1.default.language.java.value)) {
|
|
150
|
+
yield (0, ensure_java_userconfig_1.ensureJava)(fn);
|
|
151
|
+
yield (0, languages_1.java)(fn);
|
|
152
|
+
}
|
|
153
|
+
else if ((_c = fn.stack) === null || _c === void 0 ? void 0 : _c.startsWith(runtime_1.default.language.python.value)) {
|
|
154
|
+
yield (0, languages_1.python)(fn);
|
|
155
|
+
const reqFile = (0, path_1.join)(fn.source, constants_1.FILENAME.functions.python_requirements);
|
|
156
|
+
const requirementsExists = yield fs_1.ASYNC.readFile(reqFile);
|
|
157
|
+
if (requirementsExists && fn.valid) {
|
|
158
|
+
try {
|
|
159
|
+
yield (0, python_1.removeRequirements)(reqFile, fn);
|
|
160
|
+
}
|
|
161
|
+
catch (e) {
|
|
162
|
+
const err = error_1.default.getErrorInstance(e);
|
|
163
|
+
(fn.valid = false), (fn.failure_reason = err.message);
|
|
164
|
+
}
|
|
159
165
|
}
|
|
160
166
|
}
|
|
167
|
+
const catalystJsonPth = (0, path_1.join)(fn.source, constants_1.FILENAME.catalyst_config);
|
|
168
|
+
const catalystJson = yield fs_1.ASYNC.readJSONFile(catalystJsonPth);
|
|
169
|
+
const fnDetails = (yield fnAPI.getFunction(fn.id));
|
|
170
|
+
const envVariables = js_1.JS.get(fnDetails, 'configuration.environment.variables', false);
|
|
171
|
+
if (catalystJson && envVariables) {
|
|
172
|
+
catalystJson.deployment.env_variables = envVariables;
|
|
173
|
+
yield fs_1.ASYNC.writeJSONFile(catalystJsonPth, catalystJson);
|
|
174
|
+
}
|
|
175
|
+
isFnPulled = true;
|
|
161
176
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
177
|
+
catch (err) {
|
|
178
|
+
const error = err;
|
|
179
|
+
let message = error.message;
|
|
180
|
+
if (error instanceof error_1.default) {
|
|
181
|
+
if (error.errorId && error.errorId === 'JAVACONFIG-3') {
|
|
182
|
+
message = `You are trying to pull a function of a higher stack version[${fn.stack}]. Please provide a valid java binary path for the config key ${fn.stack}.bin to pull function[${fn.name}].`;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
throbber.remove('function_pull_' + fn.name);
|
|
186
|
+
(0, logger_1.warning)(`Skipping pull of function(${fn.name}). ${message}`);
|
|
187
|
+
fn.failure_reason = `there was an error while pulling function [${fn.name}]. ${message}`;
|
|
188
|
+
isFnPulledFailed = true;
|
|
169
189
|
}
|
|
170
190
|
throbber.remove('function_pull_' + fn.name);
|
|
171
191
|
return fn;
|
|
172
192
|
})));
|
|
173
193
|
targets = targets.filter((target) => {
|
|
174
|
-
var _a, _b;
|
|
175
|
-
if (!target.valid &&
|
|
194
|
+
var _a, _b, _c;
|
|
195
|
+
if (!target.valid &&
|
|
196
|
+
!((_a = target.failure_reason) === null || _a === void 0 ? void 0 : _a.startsWith('unable to locate python')) &&
|
|
197
|
+
!((_b = target.failure_reason) === null || _b === void 0 ? void 0 : _b.includes('You are trying to pull a function of a higher stack version'))) {
|
|
176
198
|
(0, logger_1.debug)('Invalid target : ' + target.name + ' reason : ' + target.failure_reason);
|
|
177
199
|
(0, logger_1.warning)(`skipping pull of function(${target.name}) since the package is invalid. \nContact catalyst support with debug log.`);
|
|
178
200
|
new error_1.default('invalid package: ' + target.name, { exit: 2 });
|
|
179
201
|
}
|
|
180
|
-
else if (!target.valid && ((
|
|
202
|
+
else if (!target.valid && ((_c = target.failure_reason) === null || _c === void 0 ? void 0 : _c.startsWith('unable to locate python'))) {
|
|
181
203
|
(0, logger_1.warning)(`skipping pull of function(${target.name}) since ${target.failure_reason}`);
|
|
182
204
|
}
|
|
183
205
|
return target.valid;
|
|
184
206
|
});
|
|
185
|
-
|
|
186
|
-
|
|
207
|
+
if (isFnPulled) {
|
|
208
|
+
runtime_store_1.default.set('payload.functions.targets', targets);
|
|
209
|
+
runtime_store_1.default.set('payload.functions.source', fnDirName);
|
|
210
|
+
if (isFnPulledFailed) {
|
|
211
|
+
runtime_store_1.default.set('payload.functions.status', 1);
|
|
212
|
+
}
|
|
213
|
+
else {
|
|
214
|
+
runtime_store_1.default.set('payload.functions.status', 2);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
187
217
|
});
|
package/lib/serve/index.js
CHANGED
|
@@ -51,6 +51,7 @@ const logger_1 = require("../util_modules/logger");
|
|
|
51
51
|
const option_1 = require("../util_modules/option");
|
|
52
52
|
const features = __importStar(require("./features"));
|
|
53
53
|
const server_1 = __importDefault(require("./server"));
|
|
54
|
+
const char_1 = require("../util_modules/char");
|
|
54
55
|
exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
55
56
|
const serveTargets = runtime_store_1.default.get('context.targets', []);
|
|
56
57
|
const advancedServer = new server_1.default();
|
|
@@ -89,6 +90,11 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
89
90
|
}
|
|
90
91
|
const functionTargets = rawTargets.filter((target) => {
|
|
91
92
|
var _a;
|
|
93
|
+
if (target.compilationError) {
|
|
94
|
+
target.compilationError.forEach((error) => {
|
|
95
|
+
console.log(`${(0, ansi_colors_1.red)(char_1.CHAR.error)} Error while compiling function[${target.name}] : ${error}`);
|
|
96
|
+
});
|
|
97
|
+
}
|
|
92
98
|
if (!target.valid) {
|
|
93
99
|
(0, logger_1.warning)('skipping serve of function [' +
|
|
94
100
|
target.name +
|
|
@@ -96,6 +102,11 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
96
102
|
target.failure_reason);
|
|
97
103
|
return false;
|
|
98
104
|
}
|
|
105
|
+
if (target.compilationWarning) {
|
|
106
|
+
target.compilationWarning.forEach((message) => {
|
|
107
|
+
(0, logger_1.warning)(message);
|
|
108
|
+
});
|
|
109
|
+
}
|
|
99
110
|
if (target.type === constants_1.FN_TYPE.advanced) {
|
|
100
111
|
advancedServer.add('server', target);
|
|
101
112
|
}
|
|
@@ -171,7 +182,7 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
171
182
|
}).catch((err) => (0, logger_1.debug)('Error modifying the permissions: ', err)));
|
|
172
183
|
(0, logger_1.info)('Shutting down server');
|
|
173
184
|
yield Promise.all([
|
|
174
|
-
fs_1.ASYNC.deleteDir(buildFolder).catch(),
|
|
185
|
+
fs_1.ASYNC.deleteDir(buildFolder).catch((err) => (0, logger_1.debug)('Error while deleting directory ', err)),
|
|
175
186
|
advancedServer ? advancedServer.stop() : undefined,
|
|
176
187
|
basicFnServer ? basicFnServer.stop() : undefined
|
|
177
188
|
]);
|
|
@@ -14,14 +14,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
const path_1 = require("path");
|
|
16
16
|
const fn_utils_1 = require("../../../../fn-utils");
|
|
17
|
+
const ensure_java_userconfig_1 = require("../../../../fn-utils/lib/ensure-java-userconfig");
|
|
17
18
|
const plugin_loader_1 = __importDefault(require("../../../../plugin-loader"));
|
|
18
19
|
const runtime_store_1 = __importDefault(require("../../../../runtime-store"));
|
|
20
|
+
const userConfig_1 = __importDefault(require("../../../../userConfig"));
|
|
19
21
|
const constants_1 = require("../../../../util_modules/constants");
|
|
20
22
|
const logger_1 = require("../../../../util_modules/logger");
|
|
21
23
|
const project_1 = require("../../../../util_modules/project");
|
|
22
24
|
const shell_1 = require("../../../../util_modules/shell");
|
|
23
25
|
exports.default = (details, masterPort) => __awaiter(void 0, void 0, void 0, function* () {
|
|
24
|
-
var _a, _b, _c;
|
|
26
|
+
var _a, _b, _c, _d, _e;
|
|
25
27
|
const cwd = runtime_store_1.default.get('cwd');
|
|
26
28
|
const javaServer = (0, path_1.join)(cwd, constants_1.FOLDERNAME.build, '.catalyst', 'aioserver', 'JavaaioServer');
|
|
27
29
|
const targetDir = (0, path_1.join)(cwd, constants_1.FOLDERNAME.build, constants_1.FOLDERNAME.functions, (_a = details.target) === null || _a === void 0 ? void 0 : _a.name);
|
|
@@ -46,7 +48,10 @@ exports.default = (details, masterPort) => __awaiter(void 0, void 0, void 0, fun
|
|
|
46
48
|
(0, logger_1.labeled)(label, `Plugin : "${runtime_store_1.default.get(`context.${configType}.plugins.start${targetSource ? '.' + targetSource : ''}`)}" is used for ${details.type} serve`).MESSAGE();
|
|
47
49
|
return event;
|
|
48
50
|
}
|
|
49
|
-
|
|
51
|
+
const configKey = `${(_d = details.target) === null || _d === void 0 ? void 0 : _d.stack}.bin`;
|
|
52
|
+
const userConfigCmd = userConfig_1.default.get(configKey);
|
|
53
|
+
const spawnCommand = (0, ensure_java_userconfig_1.getJavaSpawnCommand)(userConfigCmd, 'java', (_e = details.target) === null || _e === void 0 ? void 0 : _e.stack);
|
|
54
|
+
return (0, shell_1.spawn)(spawnCommand, opts, {
|
|
50
55
|
cwd: targetSource === null || targetSource === void 0 ? void 0 : targetSource.replace(cwd, (0, path_1.join)(cwd, constants_1.FOLDERNAME.build)),
|
|
51
56
|
stdio: 'pipe',
|
|
52
57
|
env: Object.assign({ X_ZOHO_CATALYST_IS_LOCAL: 'true', X_ZOHO_CATALYST_FUNCTION_LOADED: 'true', X_ZOHO_CATALYST_CODE_LOCATION: targetDir + path_1.sep, X_ZOHO_CATALYST_ACCOUNTS_URL: constants_1.ORIGIN.auth, X_ZOHO_CATALYST_CONSOLE_URL: constants_1.ORIGIN.admin, CATALYST_PROJECT_TIMEZONE: (0, project_1.getProjectTimezone)(Intl.DateTimeFormat().resolvedOptions().timeZone) }, details.target.env_var)
|
|
@@ -105,10 +105,25 @@ function spinUpMaster(listenPort, otherServerDetails) {
|
|
|
105
105
|
const customProxyUrl = (0, option_1.getOptionValue)('proxy');
|
|
106
106
|
const app = (0, express_1.default)();
|
|
107
107
|
let systemRoutes;
|
|
108
|
+
const nonApigURL = ['/accounts', '/clientoauth', '/_wms', '/wmssrv'];
|
|
108
109
|
app.use((0, logger_1.default)((_a = otherServerDetails.appSail) === null || _a === void 0 ? void 0 : _a.at(0)));
|
|
109
110
|
app.use(cookie_parser_1.default);
|
|
110
111
|
app.use((0, project_1.default)(projectDetails));
|
|
111
112
|
app.use(authenticator_1.default);
|
|
113
|
+
app.use(nonApigURL, (req, res) => {
|
|
114
|
+
req.url = req.originalUrl;
|
|
115
|
+
(0, unknownReqProxy_1.default)(proxy, customProxyUrl)(req, res);
|
|
116
|
+
});
|
|
117
|
+
app.use('*/.catalyst%2Freload-script.js', (req, res) => {
|
|
118
|
+
var _a;
|
|
119
|
+
(_a = otherServerDetails.client) === null || _a === void 0 ? void 0 : _a.forEach((clientDetails) => {
|
|
120
|
+
const appTarget = `http://127.0.0.1:${clientDetails.httpPort}/app/`;
|
|
121
|
+
proxy.web(req, res, {
|
|
122
|
+
target: appTarget,
|
|
123
|
+
changeOrigin: true
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
});
|
|
112
127
|
if (rules !== -1) {
|
|
113
128
|
for (const [sourceURL, methodByConfig] of Object.entries(rules)) {
|
|
114
129
|
const router = app.route(sourceURL);
|
|
@@ -130,7 +145,10 @@ function spinUpMaster(listenPort, otherServerDetails) {
|
|
|
130
145
|
}
|
|
131
146
|
app.use('/', apig_matcher_1.default, auth_checker_1.default, url_rewriter_1.default);
|
|
132
147
|
}
|
|
133
|
-
const proxy = (0, http_proxy_1.createProxyServer)(
|
|
148
|
+
const proxy = (0, http_proxy_1.createProxyServer)({
|
|
149
|
+
hostRewrite: `localhost:${listenPort}`,
|
|
150
|
+
protocolRewrite: 'http'
|
|
151
|
+
})
|
|
134
152
|
.on('error', (err, req, res) => {
|
|
135
153
|
if (res instanceof http_1.ServerResponse) {
|
|
136
154
|
res.writeHead(502, { 'Content-Type': 'json' });
|
|
@@ -248,11 +266,18 @@ function spinUpMaster(listenPort, otherServerDetails) {
|
|
|
248
266
|
case 'appSail': {
|
|
249
267
|
(_d = otherServerDetails.appSail) === null || _d === void 0 ? void 0 : _d.forEach((appSailDetails) => {
|
|
250
268
|
app.use('/', (req, res) => {
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
}
|
|
269
|
+
var _a, _b, _c;
|
|
270
|
+
if ((_b = (_a = appSailDetails.target) === null || _a === void 0 ? void 0 : _a.url) === null || _b === void 0 ? void 0 : _b.includes('/__catalyst/sdk/init.js')) {
|
|
271
|
+
req.url = (_c = appSailDetails.target) === null || _c === void 0 ? void 0 : _c.url;
|
|
272
|
+
(0, unknownReqProxy_1.default)(proxy, customProxyUrl)(req, res);
|
|
273
|
+
}
|
|
274
|
+
else {
|
|
275
|
+
proxy.web(req, res, {
|
|
276
|
+
target: `http://127.0.0.1:${appSailDetails.target.port
|
|
277
|
+
.appsail}`,
|
|
278
|
+
ws: true
|
|
279
|
+
});
|
|
280
|
+
}
|
|
256
281
|
});
|
|
257
282
|
});
|
|
258
283
|
break;
|
|
@@ -24,13 +24,17 @@ const util_1 = require("util");
|
|
|
24
24
|
exports.default = (details) => __awaiter(void 0, void 0, void 0, function* () {
|
|
25
25
|
var _a, _b;
|
|
26
26
|
const projectRoot = runtime_store_1.default.get('project.root');
|
|
27
|
-
const opts = ['-u', 'main.py'];
|
|
28
27
|
const targetSource = (_a = details.target) === null || _a === void 0 ? void 0 : _a.source;
|
|
29
28
|
const runtimesDir = constants_1.ENVPATH.runtimes.data;
|
|
29
|
+
const cwd = runtime_store_1.default.get('cwd');
|
|
30
30
|
const stackVersion = (_b = details.target.stack) === null || _b === void 0 ? void 0 : _b.replace('python_', '');
|
|
31
|
+
const opts = [
|
|
32
|
+
'-u',
|
|
33
|
+
(0, path_1.join)(runtimesDir, constants_1.RUNTIME.language.python.value, `zcatalyst_runtime_${stackVersion === null || stackVersion === void 0 ? void 0 : stackVersion.replace('_', '')}`, 'main.py')
|
|
34
|
+
];
|
|
31
35
|
return new Promise((res) => {
|
|
32
36
|
const child = (0, shell_1.spawn)(userConfig_1.default.get(`python${stackVersion}.bin`), opts, {
|
|
33
|
-
cwd:
|
|
37
|
+
cwd: targetSource === null || targetSource === void 0 ? void 0 : targetSource.replace(cwd, (0, path_1.join)(cwd, constants_1.FOLDERNAME.build)),
|
|
34
38
|
stdio: 'pipe',
|
|
35
39
|
env: Object.assign({ X_ZOHO_CATALYST_IS_LOCAL: 'true', X_ZOHO_CATALYST_FUNCTION_LOADED: 'true', X_ZOHO_CATALYST_ACCOUNTS_URL: constants_1.ORIGIN.auth, X_ZOHO_CATALYST_CONSOLE_URL: constants_1.ORIGIN.admin, X_ZOHO_CATALYST_CODE_LOCATION: targetSource === null || targetSource === void 0 ? void 0 : targetSource.replace(projectRoot, (0, path_1.join)(projectRoot, constants_1.FOLDERNAME.build)), X_ZOHO_CATALYST_SERVER_LISTEN_PORT: details.httpPort.toString(), CATALYST_PROJECT_TIMEZONE: (0, project_1.getProjectTimezone)(Intl.DateTimeFormat().resolvedOptions().timeZone) }, details.target.env_var)
|
|
36
40
|
}).RAW();
|
|
@@ -28,10 +28,12 @@ const constants_1 = require("../../util_modules/constants");
|
|
|
28
28
|
const runtime_1 = __importDefault(require("../../util_modules/constants/lib/runtime"));
|
|
29
29
|
const fs_1 = require("../../util_modules/fs");
|
|
30
30
|
const js_1 = require("../../util_modules/js");
|
|
31
|
+
const userConfig_1 = __importDefault(require("../../userConfig"));
|
|
31
32
|
const logger_2 = require("../../util_modules/logger");
|
|
32
33
|
const project_2 = require("../../util_modules/project");
|
|
33
34
|
const shell_1 = require("../../util_modules/shell");
|
|
34
35
|
const request_1 = __importDefault(require("request"));
|
|
36
|
+
const ensure_java_userconfig_1 = require("../../fn-utils/lib/ensure-java-userconfig");
|
|
35
37
|
const option_1 = require("../../util_modules/option");
|
|
36
38
|
const server_1 = require("../../util_modules/server");
|
|
37
39
|
const logUrl = (name, pthName, httpPort, masterPort) => {
|
|
@@ -79,7 +81,7 @@ class HttpFunctions {
|
|
|
79
81
|
[constants_1.FN_TYPE.basic]: (0, path_1.normalize)((0, path_1.join)(__dirname, './invoker', constants_1.FN_TYPE.basic, 'node.mjs'))
|
|
80
82
|
};
|
|
81
83
|
this.javaInvoker = {
|
|
82
|
-
[constants_1.FN_TYPE.basic]: (0, path_1.join)(projectRoot, constants_1.FOLDERNAME.build, '.catalyst'
|
|
84
|
+
[constants_1.FN_TYPE.basic]: (0, path_1.join)(projectRoot, constants_1.FOLDERNAME.build, '.catalyst')
|
|
83
85
|
};
|
|
84
86
|
this.requestFile = (0, path_1.join)(projectRoot, constants_1.FOLDERNAME.build, '.catalyst', 'user_req_body');
|
|
85
87
|
this.responseFile = (0, path_1.join)(projectRoot, constants_1.FOLDERNAME.build, '.catalyst', 'user_res_body');
|
|
@@ -214,7 +216,10 @@ class HttpFunctions {
|
|
|
214
216
|
});
|
|
215
217
|
}
|
|
216
218
|
else if ((_b = fnTarget.stack) === null || _b === void 0 ? void 0 : _b.startsWith(runtime_1.default.language.java.value)) {
|
|
217
|
-
const
|
|
219
|
+
const invoker = fnTarget.type === constants_1.FN_TYPE.basic
|
|
220
|
+
? this.javaInvoker[fnTarget.type] + `/${fnTarget.stack}/JavabioInvoker`
|
|
221
|
+
: this.javaInvoker[fnTarget.type];
|
|
222
|
+
const javaInvokerDir = (0, path_1.parse)(invoker).dir;
|
|
218
223
|
slaveOptions.push('-cp');
|
|
219
224
|
slaveOptions.push(javaInvokerDir +
|
|
220
225
|
fn_utils_1.fnUtils.java.classPathSep +
|
|
@@ -225,7 +230,7 @@ class HttpFunctions {
|
|
|
225
230
|
debugPort +
|
|
226
231
|
',server=y,suspend=y');
|
|
227
232
|
}
|
|
228
|
-
slaveOptions.push((0, path_1.basename)(
|
|
233
|
+
slaveOptions.push((0, path_1.basename)(invoker));
|
|
229
234
|
slaveOptions.push(javaInvokerDir);
|
|
230
235
|
slaveOptions.push(JSON.stringify(fnTarget));
|
|
231
236
|
slaveOptions.push(query);
|
|
@@ -243,9 +248,13 @@ class HttpFunctions {
|
|
|
243
248
|
'x-zc-cookie': request.headers['x-zc-cookie'],
|
|
244
249
|
'x-zc-user-type': request.headers['x-zc-user-type']
|
|
245
250
|
}));
|
|
251
|
+
const configKey = `${fnTarget.stack}.bin`;
|
|
252
|
+
const userConfigCmd = userConfig_1.default.get(configKey);
|
|
253
|
+
const spawnCommand = (0, ensure_java_userconfig_1.getJavaSpawnCommand)(userConfigCmd, 'java', fnTarget.stack);
|
|
246
254
|
slave = this.q.push({
|
|
247
|
-
command:
|
|
255
|
+
command: spawnCommand,
|
|
248
256
|
options: slaveOptions,
|
|
257
|
+
target: fnTarget,
|
|
249
258
|
pth: (0, path_1.join)(runtime_store_1.default.get('project.root'), constants_1.FOLDERNAME.build, constants_1.FOLDERNAME.functions, fnTarget.name),
|
|
250
259
|
req: request,
|
|
251
260
|
id: fnTarget.name,
|
|
@@ -299,7 +308,11 @@ class HttpFunctions {
|
|
|
299
308
|
.forEach((t) => {
|
|
300
309
|
var _a;
|
|
301
310
|
if ((_a = t.stack) === null || _a === void 0 ? void 0 : _a.startsWith(runtime_1.default.language.java.value)) {
|
|
302
|
-
|
|
311
|
+
const invoker = t.type === constants_1.FN_TYPE.basic
|
|
312
|
+
? this.javaInvoker[t.type] +
|
|
313
|
+
`/${t.stack}/JavabioInvoker`
|
|
314
|
+
: this.javaInvoker[t.type];
|
|
315
|
+
fn_utils_1.fnUtils.java.ensureJavaInvoker(invoker, (0, path_1.normalize)((0, path_1.join)(__dirname, './invoker', t.type, 'java', 'Java' + t.type + 'Invoker.java')), t);
|
|
303
316
|
}
|
|
304
317
|
const pthName = new url_1.URL(t.url).pathname;
|
|
305
318
|
if (pthName !== null) {
|
|
@@ -91,9 +91,8 @@ public class JavabioInvoker {
|
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
private static void writeResponse(JSONObject responseJson, JSONObject metaJson, String invokerDir) throws Exception {
|
|
94
|
-
String responseFilePath = Paths.get(invokerDir, "user_res_body").toString();
|
|
95
|
-
String responseMeta = Paths.get(invokerDir, "user_meta.json").toString();
|
|
96
|
-
|
|
94
|
+
String responseFilePath = Paths.get(invokerDir, "../user_res_body").toString();
|
|
95
|
+
String responseMeta = Paths.get(invokerDir, "../user_meta.json").toString();
|
|
97
96
|
BufferedWriter responseWriter = new BufferedWriter(new FileWriter(responseFilePath));
|
|
98
97
|
String responseStr = responseJson.toString();
|
|
99
98
|
responseWriter.write(responseStr);
|
|
@@ -194,7 +193,7 @@ public class JavabioInvoker {
|
|
|
194
193
|
LogHandler handler = new JavabioInvoker().new LogHandler();
|
|
195
194
|
rootLogger.addHandler(handler);
|
|
196
195
|
|
|
197
|
-
Path requestFilePath = Paths.get(invokerDir, "user_req_body");
|
|
196
|
+
Path requestFilePath = Paths.get(invokerDir, "../user_req_body");
|
|
198
197
|
|
|
199
198
|
HashMap<String, Object> userBody = new HashMap<String, Object>();
|
|
200
199
|
|
|
@@ -222,8 +221,7 @@ public class JavabioInvoker {
|
|
|
222
221
|
HashMap<String, Object> target = jsonToMap(args[1]);
|
|
223
222
|
String fnExeName = (String) target.get("index");
|
|
224
223
|
String fnName = (String) target.get("name");
|
|
225
|
-
String fnExePath = Paths.get(invokerDir, "
|
|
226
|
-
|
|
224
|
+
String fnExePath = Paths.get(invokerDir, "../../", "functions", fnName).normalize().toString();
|
|
227
225
|
HashMap<String, Object> queryData = jsonToMap(args[2]);
|
|
228
226
|
HashMap<String, Object> projectData = jsonToMap(args[3]);
|
|
229
227
|
HashMap<String, Object> authData = jsonToMap(args[4]);
|
|
@@ -92,8 +92,7 @@ public class JavacronInvoker {
|
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
private static void writeResponse(String response, String invokerDir) throws Exception {
|
|
95
|
-
String responseFilePath = Paths.get(invokerDir, "user_res_body").toString();
|
|
96
|
-
|
|
95
|
+
String responseFilePath = Paths.get(invokerDir, "../user_res_body").toString();
|
|
97
96
|
BufferedWriter responseWriter = new BufferedWriter(new FileWriter(responseFilePath));
|
|
98
97
|
responseWriter.write(response);
|
|
99
98
|
responseWriter.close();
|
|
@@ -168,7 +167,7 @@ public class JavacronInvoker {
|
|
|
168
167
|
LogHandler handler = new JavacronInvoker().new LogHandler();
|
|
169
168
|
rootLogger.addHandler(handler);
|
|
170
169
|
|
|
171
|
-
Path requestFilePath = Paths.get(invokerDir, "user_req_body");
|
|
170
|
+
Path requestFilePath = Paths.get(invokerDir, "../user_req_body");
|
|
172
171
|
|
|
173
172
|
HashMap<String, Object> userBody = new HashMap<String, Object>();
|
|
174
173
|
|
|
@@ -196,7 +195,7 @@ public class JavacronInvoker {
|
|
|
196
195
|
HashMap<String, Object> target = jsonToMap(args[1]);
|
|
197
196
|
String fnExeName = (String) target.get("index");
|
|
198
197
|
String fnName = (String) target.get("name");
|
|
199
|
-
String fnExePath = Paths.get(invokerDir, "
|
|
198
|
+
String fnExePath = Paths.get(invokerDir, "../../", "functions", fnName).normalize().toString();
|
|
200
199
|
|
|
201
200
|
HashMap<String, Object> queryData = jsonToMap(args[2]);
|
|
202
201
|
HashMap<String, Object> projectData = jsonToMap(args[3]);
|
|
@@ -92,7 +92,7 @@ public class JavaeventInvoker {
|
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
private static void writeResponse(String response, String invokerDir) throws Exception {
|
|
95
|
-
String responseFilePath = Paths.get(invokerDir, "user_res_body").toString();
|
|
95
|
+
String responseFilePath = Paths.get(invokerDir, "../user_res_body").toString();
|
|
96
96
|
|
|
97
97
|
BufferedWriter responseWriter = new BufferedWriter(new FileWriter(responseFilePath));
|
|
98
98
|
responseWriter.write(response);
|
|
@@ -168,7 +168,7 @@ public class JavaeventInvoker {
|
|
|
168
168
|
LogHandler handler = new JavaeventInvoker().new LogHandler();
|
|
169
169
|
rootLogger.addHandler(handler);
|
|
170
170
|
|
|
171
|
-
Path requestFilePath = Paths.get(invokerDir, "user_req_body");
|
|
171
|
+
Path requestFilePath = Paths.get(invokerDir, "../user_req_body");
|
|
172
172
|
|
|
173
173
|
HashMap<String, Object> userBody = new HashMap<String, Object>();
|
|
174
174
|
|
|
@@ -196,12 +196,10 @@ public class JavaeventInvoker {
|
|
|
196
196
|
HashMap<String, Object> target = jsonToMap(args[1]);
|
|
197
197
|
String fnExeName = (String) target.get("index");
|
|
198
198
|
String fnName = (String) target.get("name");
|
|
199
|
-
String fnExePath = Paths.get(invokerDir, "
|
|
200
|
-
|
|
199
|
+
String fnExePath = Paths.get(invokerDir, "../../", "functions", fnName).normalize().toString();
|
|
201
200
|
HashMap<String, Object> queryData = jsonToMap(args[2]);
|
|
202
201
|
HashMap<String, Object> projectData = jsonToMap(args[3]);
|
|
203
202
|
HashMap<String, Object> authData = jsonToMap(args[4]);
|
|
204
|
-
|
|
205
203
|
File[] jarFiles = new File(fnExePath).listFiles(new FilenameFilter() {
|
|
206
204
|
@Override
|
|
207
205
|
public boolean accept(File dir, String name) {
|
|
@@ -89,7 +89,7 @@ public class JavaintegInvoker {
|
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
private static void writeResponse(String responseString, String invokerDir) throws Exception {
|
|
92
|
-
String responseFilePath = Paths.get(invokerDir, "user_res_body").toString();
|
|
92
|
+
String responseFilePath = Paths.get(invokerDir, "../user_res_body").toString();
|
|
93
93
|
|
|
94
94
|
BufferedWriter responseWriter = new BufferedWriter(new FileWriter(responseFilePath));
|
|
95
95
|
responseWriter.write(responseString);
|
|
@@ -172,7 +172,7 @@ public class JavaintegInvoker {
|
|
|
172
172
|
HashMap<String, Object> target = jsonToMap(args[1]);
|
|
173
173
|
String fnExeName = (String) target.get("index");
|
|
174
174
|
String fnName = (String) target.get("name");
|
|
175
|
-
String fnExePath = Paths.get(invokerDir, "
|
|
175
|
+
String fnExePath = Paths.get(invokerDir, "../../", "functions", fnName).normalize().toString();
|
|
176
176
|
|
|
177
177
|
Path configJsonPath = Paths.get(fnExePath, "catalyst-config.json");
|
|
178
178
|
|
|
@@ -28,6 +28,7 @@ const logger_1 = require("../../util_modules/logger");
|
|
|
28
28
|
const project_1 = require("../../util_modules/project");
|
|
29
29
|
const shell_1 = require("../../util_modules/shell");
|
|
30
30
|
const http_functions_1 = require("../dependencies/http-functions");
|
|
31
|
+
const ensure_java_userconfig_1 = require("../../fn-utils/lib/ensure-java-userconfig");
|
|
31
32
|
class LocalFunction {
|
|
32
33
|
constructor(repl, target) {
|
|
33
34
|
var _a, _b, _c;
|
|
@@ -41,9 +42,9 @@ class LocalFunction {
|
|
|
41
42
|
this.slave = null;
|
|
42
43
|
this.nodeInvoker = (0, path_1.normalize)((0, path_1.join)(__dirname, './invoker', target.type, 'node.mjs'));
|
|
43
44
|
const projectRoot = runtime_store_1.default.get('project.root');
|
|
44
|
-
this.javaInvoker = (0, path_1.join)(projectRoot, constants_1.FOLDERNAME.build, '.catalyst', 'Java' + target.type + 'Invoker');
|
|
45
|
+
this.javaInvoker = (0, path_1.join)(projectRoot, constants_1.FOLDERNAME.build, '.catalyst', target.stack, 'Java' + target.type + 'Invoker');
|
|
45
46
|
if ((_a = target.stack) === null || _a === void 0 ? void 0 : _a.startsWith(runtime_1.default.language.java.value)) {
|
|
46
|
-
fn_utils_1.fnUtils.java.ensureJavaInvoker(this.javaInvoker, (0, path_1.normalize)((0, path_1.join)(__dirname, './invoker', target.type, 'java', 'Java' + target.type + 'Invoker.java')));
|
|
47
|
+
fn_utils_1.fnUtils.java.ensureJavaInvoker(this.javaInvoker, (0, path_1.normalize)((0, path_1.join)(__dirname, './invoker', target.type, 'java', 'Java' + target.type + 'Invoker.java')), target);
|
|
47
48
|
}
|
|
48
49
|
this.responseFile = (0, path_1.join)(projectRoot, constants_1.FOLDERNAME.build, '.catalyst', 'user_res_body');
|
|
49
50
|
this.metaFile = (0, path_1.join)(projectRoot, constants_1.FOLDERNAME.build, '.catalyst', 'user_meta.json');
|
|
@@ -146,7 +147,10 @@ class LocalFunction {
|
|
|
146
147
|
'x-zc-admin-cred-token': accessToken,
|
|
147
148
|
'x-zc-user-type': 'admin'
|
|
148
149
|
}));
|
|
149
|
-
|
|
150
|
+
const configKey = `${this.target.stack}.bin`;
|
|
151
|
+
const userConfigCmd = userConfig_1.default.get(configKey);
|
|
152
|
+
const spawnCommand = (0, ensure_java_userconfig_1.getJavaSpawnCommand)(userConfigCmd, 'java', this.target.stack);
|
|
153
|
+
this.slave = (0, shell_1.spawn)(spawnCommand, slaveOptions, {
|
|
150
154
|
cwd: (0, path_1.join)(projectRoot, constants_1.FOLDERNAME.build, constants_1.FOLDERNAME.functions, this.target.name),
|
|
151
155
|
stdio: 'pipe',
|
|
152
156
|
env: Object.assign({ X_ZOHO_CATALYST_IS_LOCAL: 'true', X_ZOHO_CATALYST_FUNCTION_LOADED: 'true', X_ZOHO_CATALYST_ACCOUNTS_URL: constants_1.ORIGIN.auth, X_ZOHO_CATALYST_CONSOLE_URL: constants_1.ORIGIN.admin, CATALYST_PROJECT_TIMEZONE: (0, project_1.getProjectTimezone)(Intl.DateTimeFormat().resolvedOptions().timeZone) }, this.target.env_var)
|
|
@@ -52,9 +52,9 @@ exports.default = (targets) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
52
52
|
if (target.type === constants_1.FN_TYPE.advanced ||
|
|
53
53
|
target.type === constants_1.FN_TYPE.applogic ||
|
|
54
54
|
target.type === constants_1.FN_TYPE.browserLogic) {
|
|
55
|
-
const javaServer = (0, path_1.join)(projectRoot, constants_1.FOLDERNAME.build, '.catalyst', 'aioserver', 'JavaaioServer');
|
|
55
|
+
const javaServer = (0, path_1.join)(projectRoot, constants_1.FOLDERNAME.build, '.catalyst', target.stack, 'aioserver', 'JavaaioServer');
|
|
56
56
|
const javaInvoker = (0, path_1.join)(__dirname, '../../../serve/server/lib/java/aio_server/JavaaioServer.java');
|
|
57
|
-
(0, java_1.ensureJavaInvoker)(javaServer, javaInvoker);
|
|
57
|
+
(0, java_1.ensureJavaInvoker)(javaServer, javaInvoker, target);
|
|
58
58
|
const serverFiles = yield fs_1.ASYNC.walk((0, path_1.dirname)(javaServer));
|
|
59
59
|
yield Promise.all(serverFiles.map((file) => __awaiter(void 0, void 0, void 0, function* () {
|
|
60
60
|
try {
|
package/lib/userConfig.js
CHANGED
|
@@ -9,7 +9,7 @@ const path_1 = __importDefault(require("path"));
|
|
|
9
9
|
const error_1 = __importDefault(require("./error"));
|
|
10
10
|
class UserConfig {
|
|
11
11
|
constructor() {
|
|
12
|
-
this.validKeys = ['python3_9.bin'];
|
|
12
|
+
this.validKeys = ['python3_9.bin', 'java8.bin', 'java11.bin', 'java17.bin'];
|
|
13
13
|
this.configFilePath = path_1.default.join(constants_1.ENVPATH.userConfig.config, '.zcconfig');
|
|
14
14
|
this.config = fs_1.SYNC.readJSONFile(this.configFilePath, { checkpath: true }) || {};
|
|
15
15
|
}
|
|
@@ -163,7 +163,7 @@ exports.default = Object.freeze([
|
|
|
163
163
|
},
|
|
164
164
|
{
|
|
165
165
|
name: 'catalyst_default_get_folder',
|
|
166
|
-
source_endpoint: '/baas/v1/project/{projectId:[0-9]+}/folder/{folderId:([
|
|
166
|
+
source_endpoint: '/baas/v1/project/{projectId:[0-9]+}/folder/{folderId:([A-Za-z0-9_]+)}',
|
|
167
167
|
target_endpoint: '/baas/v1/project/{projectId}/folder/{folderId}',
|
|
168
168
|
method: 'GET',
|
|
169
169
|
authentication: undefined,
|
|
@@ -171,7 +171,7 @@ exports.default = Object.freeze([
|
|
|
171
171
|
},
|
|
172
172
|
{
|
|
173
173
|
name: 'catalyst_default_upload_file',
|
|
174
|
-
source_endpoint: '/baas/v1/project/{projectId:[0-9]+}/folder/{folderId:[
|
|
174
|
+
source_endpoint: '/baas/v1/project/{projectId:[0-9]+}/folder/{folderId:[A-Za-z0-9_]+}/file',
|
|
175
175
|
target_endpoint: '/baas/v1/project/{projectId}/folder/{folderId}/file',
|
|
176
176
|
method: 'POST',
|
|
177
177
|
authentication: undefined,
|
|
@@ -179,7 +179,7 @@ exports.default = Object.freeze([
|
|
|
179
179
|
},
|
|
180
180
|
{
|
|
181
181
|
name: 'catalyst_default_get_file',
|
|
182
|
-
source_endpoint: '/baas/v1/project/{projectId:[0-9]+}/folder/{folderId:[
|
|
182
|
+
source_endpoint: '/baas/v1/project/{projectId:[0-9]+}/folder/{folderId:[A-Za-z0-9_]+}/file/{fileId:[0-9]+}',
|
|
183
183
|
target_endpoint: '/baas/v1/project/{projectId}/folder/{folderId}/file/{fileId}',
|
|
184
184
|
method: 'GET',
|
|
185
185
|
authentication: undefined,
|
|
@@ -187,7 +187,7 @@ exports.default = Object.freeze([
|
|
|
187
187
|
},
|
|
188
188
|
{
|
|
189
189
|
name: 'catalyst_default_delete_file',
|
|
190
|
-
source_endpoint: '/baas/v1/project/{projectId:[0-9]+}/folder/{folderId:[
|
|
190
|
+
source_endpoint: '/baas/v1/project/{projectId:[0-9]+}/folder/{folderId:[A-Za-z0-9_]+}/file/{fileId:[0-9]+}',
|
|
191
191
|
target_endpoint: '/baas/v1/project/{projectId}/folder/{folderId}/file/{fileId}',
|
|
192
192
|
method: 'DELETE',
|
|
193
193
|
authentication: undefined,
|
|
@@ -195,7 +195,7 @@ exports.default = Object.freeze([
|
|
|
195
195
|
},
|
|
196
196
|
{
|
|
197
197
|
name: 'catalyst_default_download_file',
|
|
198
|
-
source_endpoint: '/baas/v1/project/{projectId:[0-9]+}/folder/{folderId:[
|
|
198
|
+
source_endpoint: '/baas/v1/project/{projectId:[0-9]+}/folder/{folderId:[A-Za-z0-9_]+}/file/{fileId:[0-9]+}/download',
|
|
199
199
|
target_endpoint: '/baas/v1/project/{projectId}/folder/{folderId}/file/{fileId}/download',
|
|
200
200
|
method: 'GET',
|
|
201
201
|
authentication: undefined,
|