@aloma.io/integration-sdk 3.0.1-1 → 3.0.1-3

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.d.mts CHANGED
@@ -1 +1,2 @@
1
+ #!/usr/bin/env node
1
2
  export {};
package/build/cli.mjs CHANGED
@@ -1,2 +1,43 @@
1
- console.log('hello world');
2
- export {};
1
+ #!/usr/bin/env node
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: '' }
9
+ ];
10
+ const extract = ({ target, name, connectorId }) => {
11
+ const source = `${__dirname}/../template/connector/`;
12
+ if (!fs.existsSync(source)) {
13
+ throw new Error(`source ${source} does not exist`);
14
+ }
15
+ files.forEach(({ name, dir }) => {
16
+ if (dir) {
17
+ fs.mkdirSync(`${target}/./${dir}`);
18
+ }
19
+ const content = fs.readFileSync(`${source}/./${dir}/${name}`, { encoding: 'utf-8' });
20
+ fs.writeFileSync(`${target}/./${dir}/${name}`, content);
21
+ console.log(content);
22
+ });
23
+ const content = JSON.parse(fs.readFileSync(`${target}/package.json`, { encoding: 'utf-8' }));
24
+ fs.writeFileSync(`${target}/package.json`, JSON.stringify(content));
25
+ };
26
+ const program = new Command();
27
+ program.name('npx @aloma.io/integration-sdk')
28
+ .description('aloma.io integration sdk')
29
+ .version('0.8.0')
30
+ .showHelpAfterError();
31
+ program.command('create')
32
+ .description('Create a new connector project')
33
+ .argument('<name>', 'name of the project')
34
+ .requiredOption('--connector-id <id>', 'id of the connector')
35
+ .action((name, options) => {
36
+ name = name.replace(/[\/\.]/gi, "");
37
+ if (!name)
38
+ throw new Error('name is empty');
39
+ const target = `${process.cwd()}/${name}`;
40
+ //fs.mkdirSync(target)
41
+ extract({ ...options, target, name });
42
+ });
43
+ program.parse();
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@aloma.io/integration-sdk",
3
- "version": "3.0.1-1",
3
+ "version": "3.0.1-3",
4
4
  "description": "",
5
5
  "author": "aloma.io",
6
6
  "license": "Apache-2.0",
7
7
  "type": "module",
8
8
  "bin": {
9
- "create-react-app": "./build/cli.js"
9
+ "main": "./build/cli.mjs"
10
10
  },
11
11
  "scripts": {
12
12
  "dev": "./node_modules/typescript/bin/tsc --watch",
@@ -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 ADDED
@@ -0,0 +1,69 @@
1
+ #!/usr/bin/env node
2
+
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
+ fs.writeFileSync(`${target}/./${dir}/${name}`, content);
33
+ console.log(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
package/src/cli.js DELETED
@@ -1 +0,0 @@
1
- console.log('hello world');