@extrahorizon/exh-cli 1.12.0-dev-141-b72e89f → 1.12.0-dev-142-82cc6de
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/build/commands/tasks/createrepo.js +6 -47
- package/build/commands/tasks/delete.js +2 -14
- package/build/commands/tasks/list.js +2 -22
- package/build/commands/tasks/sync.js +6 -80
- package/build/repositories/functions.d.ts +1 -1
- package/build/services/tasks/createRepo.d.ts +5 -0
- package/build/services/tasks/createRepo.js +52 -0
- package/build/services/tasks/index.d.ts +5 -0
- package/build/services/tasks/index.js +50 -0
- package/build/services/tasks/sync.d.ts +1 -0
- package/build/services/tasks/sync.js +84 -0
- package/package.json +1 -1
- /package/build/{commands → services}/tasks/taskConfig.d.ts +0 -0
- /package/build/{commands → services}/tasks/taskConfig.js +0 -0
- /package/build/{commands → services}/tasks/util.d.ts +0 -0
- /package/build/{commands → services}/tasks/util.js +0 -0
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.handler = exports.builder = exports.desc = exports.command = void 0;
|
|
4
|
-
const promises_1 = require("fs/promises");
|
|
5
|
-
const chalk = require("chalk");
|
|
6
4
|
const util_1 = require("../../helpers/util");
|
|
5
|
+
const tasksService = require("../../services/tasks");
|
|
7
6
|
exports.command = 'create-repo <name>';
|
|
8
7
|
exports.desc = 'Create a new task repository';
|
|
9
|
-
const builder = (yargs) => (0, util_1.epilogue)(yargs)
|
|
8
|
+
const builder = (yargs) => (0, util_1.epilogue)(yargs)
|
|
9
|
+
.positional('name', {
|
|
10
10
|
demandOption: true,
|
|
11
11
|
description: 'The name of the new repo/task',
|
|
12
12
|
type: 'string',
|
|
13
|
-
})
|
|
13
|
+
})
|
|
14
|
+
.options({
|
|
14
15
|
repo: {
|
|
15
16
|
description: 'repository template to clone',
|
|
16
17
|
type: 'string',
|
|
@@ -23,49 +24,7 @@ const builder = (yargs) => (0, util_1.epilogue)(yargs).positional('name', {
|
|
|
23
24
|
},
|
|
24
25
|
});
|
|
25
26
|
exports.builder = builder;
|
|
26
|
-
async function changePackageFile(name) {
|
|
27
|
-
try {
|
|
28
|
-
const pkg = JSON.parse((await (0, promises_1.readFile)(`${name}/package.json`)).toString());
|
|
29
|
-
pkg.name = name;
|
|
30
|
-
await (0, promises_1.writeFile)(`${name}/package.json`, JSON.stringify(pkg, null, 2));
|
|
31
|
-
}
|
|
32
|
-
catch (err) {
|
|
33
|
-
console.log('WARN: package.json not found. (possibly not a javascript repository');
|
|
34
|
-
}
|
|
35
|
-
try {
|
|
36
|
-
const taskConfig = JSON.parse((await (0, promises_1.readFile)(`${name}/task-config.json`)).toString());
|
|
37
|
-
taskConfig.$schema = (0, util_1.getSwaggerDocumentationUrl)('config-json-schemas/TaskConfig.json');
|
|
38
|
-
taskConfig.name = name;
|
|
39
|
-
taskConfig.description = `${name} task`;
|
|
40
|
-
await (0, promises_1.writeFile)(`${name}/task-config.json`, JSON.stringify(taskConfig, null, 2));
|
|
41
|
-
}
|
|
42
|
-
catch (err) { }
|
|
43
|
-
}
|
|
44
27
|
const handler = async ({ name, repo, git }) => {
|
|
45
|
-
|
|
46
|
-
await (0, util_1.asyncExec)('git --version');
|
|
47
|
-
}
|
|
48
|
-
catch (err) {
|
|
49
|
-
console.log(chalk.red('Git is not installed. Please install git first.'));
|
|
50
|
-
}
|
|
51
|
-
console.log(`Creating new repo ${chalk.green(name)}...`);
|
|
52
|
-
try {
|
|
53
|
-
await (0, util_1.asyncExec)(`git clone ${repo} ${name}`);
|
|
54
|
-
try {
|
|
55
|
-
await changePackageFile(name);
|
|
56
|
-
}
|
|
57
|
-
catch (err) { }
|
|
58
|
-
await (0, util_1.asyncExec)(`cd ${name} && rm -rf .git`);
|
|
59
|
-
if (git) {
|
|
60
|
-
console.log('Initializing git');
|
|
61
|
-
await (0, util_1.asyncExec)(`cd ${name} && git init . && git add . && git commit -m "First commit"`);
|
|
62
|
-
}
|
|
63
|
-
console.log('Done! 🎉');
|
|
64
|
-
}
|
|
65
|
-
catch (err) {
|
|
66
|
-
await (0, util_1.asyncExec)(`rm -rf ${name}`);
|
|
67
|
-
console.log(chalk.red('Failed to create repo'));
|
|
68
|
-
console.log(err);
|
|
69
|
-
}
|
|
28
|
+
await tasksService.createRepo({ name, repo, git });
|
|
70
29
|
};
|
|
71
30
|
exports.handler = handler;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.handler = exports.builder = exports.desc = exports.command = void 0;
|
|
4
|
-
const chalk = require("chalk");
|
|
5
4
|
const util_1 = require("../../helpers/util");
|
|
6
|
-
const
|
|
5
|
+
const tasksService = require("../../services/tasks");
|
|
7
6
|
exports.command = 'delete';
|
|
8
7
|
exports.desc = 'Delete a task';
|
|
9
8
|
const builder = (yargs) => (0, util_1.epilogue)(yargs).option('name', {
|
|
@@ -13,17 +12,6 @@ const builder = (yargs) => (0, util_1.epilogue)(yargs).option('name', {
|
|
|
13
12
|
});
|
|
14
13
|
exports.builder = builder;
|
|
15
14
|
const handler = async ({ name }) => {
|
|
16
|
-
|
|
17
|
-
const response = await functionRepository.remove(name);
|
|
18
|
-
if (response?.affectedRecords) {
|
|
19
|
-
console.log(chalk.green('Successfully deleted task', name));
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
console.log(chalk.red('Failed to delete task', name));
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
catch (err) {
|
|
26
|
-
console.log(chalk.red('Failed to delete task:', err.message));
|
|
27
|
-
}
|
|
15
|
+
await tasksService.remove(name);
|
|
28
16
|
};
|
|
29
17
|
exports.handler = handler;
|
|
@@ -2,32 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.handler = exports.builder = exports.desc = exports.command = void 0;
|
|
4
4
|
const util_1 = require("../../helpers/util");
|
|
5
|
-
const
|
|
5
|
+
const taskService = require("../../services/tasks");
|
|
6
6
|
exports.command = 'list';
|
|
7
7
|
exports.desc = 'List all tasks';
|
|
8
8
|
const builder = (yargs) => (0, util_1.epilogue)(yargs);
|
|
9
9
|
exports.builder = builder;
|
|
10
10
|
const handler = async function list({ isTTY }) {
|
|
11
|
-
|
|
12
|
-
try {
|
|
13
|
-
functions = await functionRepository.find();
|
|
14
|
-
}
|
|
15
|
-
catch (err) {
|
|
16
|
-
console.log(err);
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
if (functions.length < 1) {
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
if (isTTY) {
|
|
23
|
-
console.table(functions.map((c) => ({
|
|
24
|
-
Name: c.name,
|
|
25
|
-
Description: c.description || '<none>',
|
|
26
|
-
'Last updated': c.updateTimestamp.toISOString(),
|
|
27
|
-
})));
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
functions.forEach((f) => (console.log(f.name)));
|
|
31
|
-
}
|
|
11
|
+
await taskService.list(isTTY);
|
|
32
12
|
};
|
|
33
13
|
exports.handler = handler;
|
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.handler = exports.builder = exports.desc = exports.command = void 0;
|
|
4
|
-
const fs = require("fs/promises");
|
|
5
|
-
const chalk = require("chalk");
|
|
6
4
|
const constants_1 = require("../../constants");
|
|
7
5
|
const util_1 = require("../../helpers/util");
|
|
8
|
-
const
|
|
9
|
-
const taskConfig_1 = require("
|
|
10
|
-
const util_2 = require("./util");
|
|
6
|
+
const tasksService = require("../../services/tasks");
|
|
7
|
+
const taskConfig_1 = require("../../services/tasks/taskConfig");
|
|
11
8
|
exports.command = 'sync';
|
|
12
9
|
exports.desc = 'Sync a task. Will create the task first if it doesn\'t exist yet';
|
|
13
|
-
const builder = (yargs) => (0, util_1.epilogue)(yargs)
|
|
10
|
+
const builder = (yargs) => (0, util_1.epilogue)(yargs)
|
|
11
|
+
.options({
|
|
14
12
|
path: {
|
|
15
13
|
demandOption: false,
|
|
16
14
|
describe: `Path of the configuration json file containing task parameters. If a directory is given instead, all sub-directories will be searched for a task-config.json file & synced.
|
|
17
|
-
|
|
15
|
+
If this option is not used, each parameter (name, code, entryPoint, runtime, ...) will need to be supplied separately`,
|
|
18
16
|
type: 'string',
|
|
19
17
|
},
|
|
20
18
|
name: {
|
|
@@ -72,78 +70,6 @@ const builder = (yargs) => (0, util_1.epilogue)(yargs).options({
|
|
|
72
70
|
});
|
|
73
71
|
exports.builder = builder;
|
|
74
72
|
const handler = async ({ ...cmdLineParams }) => {
|
|
75
|
-
|
|
76
|
-
console.log('Syncing task', config.name, '...');
|
|
77
|
-
await syncSingleTask(config);
|
|
78
|
-
}
|
|
73
|
+
await tasksService.sync(cmdLineParams);
|
|
79
74
|
};
|
|
80
75
|
exports.handler = handler;
|
|
81
|
-
async function syncSingleTask(config) {
|
|
82
|
-
const uploadFilePath = await (0, util_2.zipFileFromDirectory)(config.path);
|
|
83
|
-
const file = await fs.readFile(uploadFilePath);
|
|
84
|
-
const allFunctions = await functionRepository.find();
|
|
85
|
-
const myFunction = allFunctions.find((f) => f.name === config.name);
|
|
86
|
-
const request = {
|
|
87
|
-
name: config.name,
|
|
88
|
-
description: config.description || 'none',
|
|
89
|
-
entryPoint: config.entryPoint,
|
|
90
|
-
code: file.toString('base64'),
|
|
91
|
-
runtime: config.runtime,
|
|
92
|
-
};
|
|
93
|
-
if (config.executionPermission || config.defaultPriority) {
|
|
94
|
-
request.executionOptions = {};
|
|
95
|
-
}
|
|
96
|
-
if (config.defaultPriority) {
|
|
97
|
-
request.executionOptions.defaultPriority = config.defaultPriority;
|
|
98
|
-
}
|
|
99
|
-
if (config.executionPermission) {
|
|
100
|
-
request.executionOptions.permissionMode = config.executionPermission;
|
|
101
|
-
}
|
|
102
|
-
if (config.timeLimit) {
|
|
103
|
-
request.timeLimit = config.timeLimit;
|
|
104
|
-
}
|
|
105
|
-
if (config.memoryLimit) {
|
|
106
|
-
request.memoryLimit = config.memoryLimit;
|
|
107
|
-
}
|
|
108
|
-
if (config.retryPolicy) {
|
|
109
|
-
request.retryPolicy = config.retryPolicy;
|
|
110
|
-
}
|
|
111
|
-
if (config.executionCredentials) {
|
|
112
|
-
const credentials = await (0, util_2.syncFunctionUser)({
|
|
113
|
-
taskName: config.name,
|
|
114
|
-
targetEmail: config.executionCredentials.email,
|
|
115
|
-
targetPermissions: config.executionCredentials.permissions,
|
|
116
|
-
});
|
|
117
|
-
config.environment = {
|
|
118
|
-
...config.environment,
|
|
119
|
-
API_HOST: process.env.API_HOST,
|
|
120
|
-
API_OAUTH_CONSUMER_KEY: process.env.API_OAUTH_CONSUMER_KEY,
|
|
121
|
-
API_OAUTH_CONSUMER_SECRET: process.env.API_OAUTH_CONSUMER_SECRET,
|
|
122
|
-
API_OAUTH_TOKEN: credentials.token,
|
|
123
|
-
API_OAUTH_TOKEN_SECRET: credentials.tokenSecret,
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
if (config.environment) {
|
|
127
|
-
const environmentVariables = {};
|
|
128
|
-
for (const [key, value] of Object.entries(config.environment)) {
|
|
129
|
-
environmentVariables[key] = { value };
|
|
130
|
-
}
|
|
131
|
-
request.environmentVariables = environmentVariables;
|
|
132
|
-
}
|
|
133
|
-
if (myFunction === undefined) {
|
|
134
|
-
await functionRepository.create(request);
|
|
135
|
-
console.log(chalk.green('Successfully created task', config.name));
|
|
136
|
-
}
|
|
137
|
-
else {
|
|
138
|
-
const existingFunction = await functionRepository.findByName(myFunction.name);
|
|
139
|
-
if (request.runtime === existingFunction.runtime) {
|
|
140
|
-
delete request.runtime;
|
|
141
|
-
}
|
|
142
|
-
const updateResponse = await functionRepository.update(request);
|
|
143
|
-
if (!updateResponse?.affectedRecords) {
|
|
144
|
-
throw new Error(`Failed to update task ${request.name}`);
|
|
145
|
-
}
|
|
146
|
-
console.log(chalk.green('Successfully updated task', config.name));
|
|
147
|
-
}
|
|
148
|
-
await fs.unlink(uploadFilePath);
|
|
149
|
-
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createRepo = void 0;
|
|
4
|
+
const promises_1 = require("fs/promises");
|
|
5
|
+
const chalk = require("chalk");
|
|
6
|
+
const util_1 = require("../../helpers/util");
|
|
7
|
+
async function createRepo({ name, repo, git }) {
|
|
8
|
+
try {
|
|
9
|
+
await (0, util_1.asyncExec)('git --version');
|
|
10
|
+
}
|
|
11
|
+
catch (err) {
|
|
12
|
+
console.log(chalk.red('Git is not installed. Please install git first.'));
|
|
13
|
+
}
|
|
14
|
+
console.log(`Creating new repo ${chalk.green(name)}...`);
|
|
15
|
+
try {
|
|
16
|
+
await (0, util_1.asyncExec)(`git clone ${repo} ${name}`);
|
|
17
|
+
try {
|
|
18
|
+
await changePackageFile(name);
|
|
19
|
+
}
|
|
20
|
+
catch (err) { }
|
|
21
|
+
await (0, util_1.asyncExec)(`cd ${name} && rm -rf .git`);
|
|
22
|
+
if (git) {
|
|
23
|
+
console.log('Initializing git');
|
|
24
|
+
await (0, util_1.asyncExec)(`cd ${name} && git init . && git add . && git commit -m "First commit"`);
|
|
25
|
+
}
|
|
26
|
+
console.log('Done! 🎉');
|
|
27
|
+
}
|
|
28
|
+
catch (err) {
|
|
29
|
+
await (0, util_1.asyncExec)(`rm -rf ${name}`);
|
|
30
|
+
console.log(chalk.red('Failed to create repo'));
|
|
31
|
+
console.log(err);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.createRepo = createRepo;
|
|
35
|
+
async function changePackageFile(name) {
|
|
36
|
+
try {
|
|
37
|
+
const pkg = JSON.parse((await (0, promises_1.readFile)(`${name}/package.json`)).toString());
|
|
38
|
+
pkg.name = name;
|
|
39
|
+
await (0, promises_1.writeFile)(`${name}/package.json`, JSON.stringify(pkg, null, 2));
|
|
40
|
+
}
|
|
41
|
+
catch (err) {
|
|
42
|
+
console.log('WARN: package.json not found. (possibly not a javascript repository');
|
|
43
|
+
}
|
|
44
|
+
try {
|
|
45
|
+
const taskConfig = JSON.parse((await (0, promises_1.readFile)(`${name}/task-config.json`)).toString());
|
|
46
|
+
taskConfig.$schema = (0, util_1.getSwaggerDocumentationUrl)('config-json-schemas/TaskConfig.json');
|
|
47
|
+
taskConfig.name = name;
|
|
48
|
+
taskConfig.description = `${name} task`;
|
|
49
|
+
await (0, promises_1.writeFile)(`${name}/task-config.json`, JSON.stringify(taskConfig, null, 2));
|
|
50
|
+
}
|
|
51
|
+
catch (err) { }
|
|
52
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.remove = exports.list = exports.assertExecutionPermission = exports.createRepo = exports.sync = void 0;
|
|
4
|
+
const chalk = require("chalk");
|
|
5
|
+
const functionRepository = require("../../repositories/functions");
|
|
6
|
+
var sync_1 = require("./sync");
|
|
7
|
+
Object.defineProperty(exports, "sync", { enumerable: true, get: function () { return sync_1.sync; } });
|
|
8
|
+
var createRepo_1 = require("./createRepo");
|
|
9
|
+
Object.defineProperty(exports, "createRepo", { enumerable: true, get: function () { return createRepo_1.createRepo; } });
|
|
10
|
+
var taskConfig_1 = require("./taskConfig");
|
|
11
|
+
Object.defineProperty(exports, "assertExecutionPermission", { enumerable: true, get: function () { return taskConfig_1.assertExecutionPermission; } });
|
|
12
|
+
async function list(isTTY) {
|
|
13
|
+
let functions;
|
|
14
|
+
try {
|
|
15
|
+
functions = await functionRepository.find();
|
|
16
|
+
}
|
|
17
|
+
catch (err) {
|
|
18
|
+
console.log(err);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
if (functions.length < 1) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
if (isTTY) {
|
|
25
|
+
console.table(functions.map((c) => ({
|
|
26
|
+
Name: c.name,
|
|
27
|
+
Description: c.description || '<none>',
|
|
28
|
+
'Last updated': c.updateTimestamp.toISOString(),
|
|
29
|
+
})));
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
functions.forEach((f) => (console.log(f.name)));
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.list = list;
|
|
36
|
+
async function remove(name) {
|
|
37
|
+
try {
|
|
38
|
+
const response = await functionRepository.remove(name);
|
|
39
|
+
if (response?.affectedRecords) {
|
|
40
|
+
console.log(chalk.green('Successfully deleted task', name));
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
console.log(chalk.red('Failed to delete task', name));
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
catch (err) {
|
|
47
|
+
console.log(chalk.red('Failed to delete task:', err.message));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.remove = remove;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function sync(cmdLineParams: any): Promise<void>;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sync = void 0;
|
|
4
|
+
const fs = require("fs/promises");
|
|
5
|
+
const chalk = require("chalk");
|
|
6
|
+
const functionRepository = require("../../repositories/functions");
|
|
7
|
+
const taskConfig_1 = require("../../services/tasks/taskConfig");
|
|
8
|
+
const util_1 = require("../../services/tasks/util");
|
|
9
|
+
async function sync(cmdLineParams) {
|
|
10
|
+
for await (const config of (0, taskConfig_1.getValidatedConfigIterator)(cmdLineParams)) {
|
|
11
|
+
console.log('Syncing task', config.name, '...');
|
|
12
|
+
await syncSingleTask(config);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.sync = sync;
|
|
16
|
+
async function syncSingleTask(config) {
|
|
17
|
+
const uploadFilePath = await (0, util_1.zipFileFromDirectory)(config.path);
|
|
18
|
+
const file = await fs.readFile(uploadFilePath);
|
|
19
|
+
const request = {
|
|
20
|
+
name: config.name,
|
|
21
|
+
description: config.description || 'none',
|
|
22
|
+
entryPoint: config.entryPoint,
|
|
23
|
+
code: file.toString('base64'),
|
|
24
|
+
runtime: config.runtime,
|
|
25
|
+
};
|
|
26
|
+
if (config.executionPermission || config.defaultPriority) {
|
|
27
|
+
request.executionOptions = {};
|
|
28
|
+
}
|
|
29
|
+
if (config.defaultPriority) {
|
|
30
|
+
request.executionOptions.defaultPriority = config.defaultPriority;
|
|
31
|
+
}
|
|
32
|
+
if (config.executionPermission) {
|
|
33
|
+
request.executionOptions.permissionMode = config.executionPermission;
|
|
34
|
+
}
|
|
35
|
+
if (config.timeLimit) {
|
|
36
|
+
request.timeLimit = config.timeLimit;
|
|
37
|
+
}
|
|
38
|
+
if (config.memoryLimit) {
|
|
39
|
+
request.memoryLimit = config.memoryLimit;
|
|
40
|
+
}
|
|
41
|
+
if (config.retryPolicy) {
|
|
42
|
+
request.retryPolicy = config.retryPolicy;
|
|
43
|
+
}
|
|
44
|
+
if (config.executionCredentials) {
|
|
45
|
+
const credentials = await (0, util_1.syncFunctionUser)({
|
|
46
|
+
taskName: config.name,
|
|
47
|
+
targetEmail: config.executionCredentials.email,
|
|
48
|
+
targetPermissions: config.executionCredentials.permissions,
|
|
49
|
+
});
|
|
50
|
+
config.environment = {
|
|
51
|
+
...config.environment,
|
|
52
|
+
API_HOST: process.env.API_HOST,
|
|
53
|
+
API_OAUTH_CONSUMER_KEY: process.env.API_OAUTH_CONSUMER_KEY,
|
|
54
|
+
API_OAUTH_CONSUMER_SECRET: process.env.API_OAUTH_CONSUMER_SECRET,
|
|
55
|
+
API_OAUTH_TOKEN: credentials.token,
|
|
56
|
+
API_OAUTH_TOKEN_SECRET: credentials.tokenSecret,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
if (config.environment) {
|
|
60
|
+
const environmentVariables = {};
|
|
61
|
+
for (const [key, value] of Object.entries(config.environment)) {
|
|
62
|
+
environmentVariables[key] = { value };
|
|
63
|
+
}
|
|
64
|
+
request.environmentVariables = environmentVariables;
|
|
65
|
+
}
|
|
66
|
+
const allFunctions = await functionRepository.find();
|
|
67
|
+
const myFunction = allFunctions.find((f) => f.name === config.name);
|
|
68
|
+
if (myFunction === undefined) {
|
|
69
|
+
await functionRepository.create(request);
|
|
70
|
+
console.log(chalk.green('Successfully created task', config.name));
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
const existingFunction = await functionRepository.findByName(myFunction.name);
|
|
74
|
+
if (request.runtime === existingFunction.runtime) {
|
|
75
|
+
delete request.runtime;
|
|
76
|
+
}
|
|
77
|
+
const updateResponse = await functionRepository.update(request);
|
|
78
|
+
if (!updateResponse?.affectedRecords) {
|
|
79
|
+
throw new Error(`Failed to update task ${request.name}`);
|
|
80
|
+
}
|
|
81
|
+
console.log(chalk.green('Successfully updated task', config.name));
|
|
82
|
+
}
|
|
83
|
+
await fs.unlink(uploadFilePath);
|
|
84
|
+
}
|
package/package.json
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|