@aloma.io/integration-sdk 3.0.1-2 → 3.0.1-4
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/cli.mjs +45 -2
- package/package.json +2 -1
- package/src/cli.mts +67 -1
- package/template/connector/package.json +48 -0
- package/template/connector/src/index.mjs +1 -0
package/build/cli.mjs
CHANGED
@@ -1,3 +1,46 @@
|
|
1
1
|
#!/usr/bin/env node
|
2
|
-
|
3
|
-
|
2
|
+
import { Command } from 'commander';
|
3
|
+
import fs from 'node:fs';
|
4
|
+
import { fileURLToPath } from 'node:url';
|
5
|
+
import path from 'node:path';
|
6
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
7
|
+
const files = [
|
8
|
+
{ name: 'index.mjs', dir: 'src' },
|
9
|
+
{ name: 'package.json', dir: '' }
|
10
|
+
];
|
11
|
+
const extract = ({ target, name, connectorId }) => {
|
12
|
+
const source = `${__dirname}/../template/connector/`;
|
13
|
+
if (!fs.existsSync(source)) {
|
14
|
+
throw new Error(`source ${source} does not exist`);
|
15
|
+
}
|
16
|
+
files.forEach(({ name, dir }) => {
|
17
|
+
if (dir) {
|
18
|
+
fs.mkdirSync(`${target}/./${dir}`);
|
19
|
+
}
|
20
|
+
const content = fs.readFileSync(`${source}/${dir}/${name}`, { encoding: 'utf-8' });
|
21
|
+
console.log(content);
|
22
|
+
fs.writeFileSync(`${target}/${dir}/${name}`, content);
|
23
|
+
});
|
24
|
+
const content = JSON.parse(fs.readFileSync(`${target}/package.json`, { encoding: 'utf-8' }));
|
25
|
+
content.name = name;
|
26
|
+
content.connectorId = connectorId;
|
27
|
+
fs.writeFileSync(`${target}/package.json`, JSON.stringify(content));
|
28
|
+
};
|
29
|
+
const program = new Command();
|
30
|
+
program.name('npx @aloma.io/integration-sdk')
|
31
|
+
.description('aloma.io integration sdk')
|
32
|
+
.version('0.8.0')
|
33
|
+
.showHelpAfterError();
|
34
|
+
program.command('create')
|
35
|
+
.description('Create a new connector project')
|
36
|
+
.argument('<name>', 'name of the project')
|
37
|
+
.requiredOption('--connector-id <id>', 'id of the connector')
|
38
|
+
.action((name, options) => {
|
39
|
+
name = name.replace(/[\/\.]/gi, "");
|
40
|
+
if (!name)
|
41
|
+
throw new Error('name is empty');
|
42
|
+
const target = `${process.cwd()}/${name}`;
|
43
|
+
fs.mkdirSync(target);
|
44
|
+
extract({ ...options, target, name });
|
45
|
+
});
|
46
|
+
program.parse();
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@aloma.io/integration-sdk",
|
3
|
-
"version": "3.0.1-
|
3
|
+
"version": "3.0.1-4",
|
4
4
|
"description": "",
|
5
5
|
"author": "aloma.io",
|
6
6
|
"license": "Apache-2.0",
|
@@ -27,6 +27,7 @@
|
|
27
27
|
"dependencies": {
|
28
28
|
"@paralleldrive/cuid2": "^2",
|
29
29
|
"@ts-ast-parser/core": "^0",
|
30
|
+
"commander": "^11",
|
30
31
|
"dotenv": "*",
|
31
32
|
"express": "^4",
|
32
33
|
"jose": "^4",
|
package/src/cli.mts
CHANGED
@@ -1,3 +1,69 @@
|
|
1
1
|
#!/usr/bin/env node
|
2
2
|
|
3
|
-
|
3
|
+
import { Command } from 'commander';
|
4
|
+
import fs from 'node:fs';
|
5
|
+
import {fileURLToPath} from 'node:url';
|
6
|
+
import path from 'node:path';
|
7
|
+
|
8
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
9
|
+
|
10
|
+
const files =
|
11
|
+
[
|
12
|
+
{name: 'index.mjs', dir: 'src'},
|
13
|
+
{name: 'package.json', dir: ''}
|
14
|
+
];
|
15
|
+
|
16
|
+
const extract = ({target, name, connectorId}) =>
|
17
|
+
{
|
18
|
+
const source = `${__dirname}/../template/connector/`;
|
19
|
+
|
20
|
+
if (!fs.existsSync(source)) {
|
21
|
+
throw new Error(`source ${source} does not exist`);
|
22
|
+
}
|
23
|
+
|
24
|
+
files.forEach(({name, dir}) =>
|
25
|
+
{
|
26
|
+
if (dir)
|
27
|
+
{
|
28
|
+
fs.mkdirSync(`${target}/./${dir}`);
|
29
|
+
}
|
30
|
+
|
31
|
+
const content = fs.readFileSync(`${source}/${dir}/${name}`, {encoding: 'utf-8'});
|
32
|
+
console.log(content);
|
33
|
+
fs.writeFileSync(`${target}/${dir}/${name}`, content);
|
34
|
+
});
|
35
|
+
|
36
|
+
const content = JSON.parse(fs.readFileSync(`${target}/package.json`, {encoding: 'utf-8'}));
|
37
|
+
|
38
|
+
content.name = name;
|
39
|
+
content.connectorId = connectorId;
|
40
|
+
|
41
|
+
fs.writeFileSync(`${target}/package.json`, JSON.stringify(content));
|
42
|
+
}
|
43
|
+
|
44
|
+
const program = new Command();
|
45
|
+
|
46
|
+
program.name('npx @aloma.io/integration-sdk')
|
47
|
+
.description('aloma.io integration sdk')
|
48
|
+
.version('0.8.0')
|
49
|
+
.showHelpAfterError();
|
50
|
+
|
51
|
+
program.command('create')
|
52
|
+
.description('Create a new connector project')
|
53
|
+
.argument('<name>', 'name of the project')
|
54
|
+
.requiredOption('--connector-id <id>', 'id of the connector')
|
55
|
+
.action((name, options) => {
|
56
|
+
name = name.replace(/[\/\.]/gi, "");
|
57
|
+
if (!name) throw new Error('name is empty');
|
58
|
+
|
59
|
+
const target = `${process.cwd()}/${name}`;
|
60
|
+
|
61
|
+
fs.mkdirSync(target)
|
62
|
+
|
63
|
+
extract({...options, target, name})
|
64
|
+
});
|
65
|
+
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
program.parse();
|
@@ -0,0 +1,48 @@
|
|
1
|
+
{
|
2
|
+
"name": "@aloma.io/integration-sdk",
|
3
|
+
"version": "3.0.1-2",
|
4
|
+
"description": "",
|
5
|
+
"author": "aloma.io",
|
6
|
+
"license": "Apache-2.0",
|
7
|
+
"type": "module",
|
8
|
+
"bin": {
|
9
|
+
"main": "./build/cli.mjs"
|
10
|
+
},
|
11
|
+
"scripts": {
|
12
|
+
"dev": "./node_modules/typescript/bin/tsc --watch",
|
13
|
+
"build": "./node_modules/typescript/bin/tsc",
|
14
|
+
"test": "./node_modules/mocha/bin/_mocha --recursive",
|
15
|
+
"format": "yarn prettier --write src/"
|
16
|
+
},
|
17
|
+
"main": "./build/index.js",
|
18
|
+
"exports": {
|
19
|
+
".": {
|
20
|
+
"import": "./build/index.mjs",
|
21
|
+
"require": "./build/index.js"
|
22
|
+
},
|
23
|
+
"./build/*": "./build/*",
|
24
|
+
"./package": "./package.json",
|
25
|
+
"./package.json": "./package.json"
|
26
|
+
},
|
27
|
+
"dependencies": {
|
28
|
+
"@paralleldrive/cuid2": "^2",
|
29
|
+
"@ts-ast-parser/core": "^0",
|
30
|
+
"commander": "^11",
|
31
|
+
"dotenv": "*",
|
32
|
+
"express": "^4",
|
33
|
+
"jose": "^4",
|
34
|
+
"node-fetch": "^2",
|
35
|
+
"prom-client": "^14",
|
36
|
+
"ws": "^8"
|
37
|
+
},
|
38
|
+
"optionalDependencies": {
|
39
|
+
"bufferutil": "^4",
|
40
|
+
"utf-8-validate": "^6"
|
41
|
+
},
|
42
|
+
"devDependencies": {
|
43
|
+
"@types/node": "^18",
|
44
|
+
"mocha": "^10",
|
45
|
+
"prettier": "^2",
|
46
|
+
"typescript": "^5"
|
47
|
+
}
|
48
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
hallo
|