@sentio/cli 2.7.2 → 2.7.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/lib/index.d.ts CHANGED
@@ -1 +1,2 @@
1
- export * from './abi.js';
1
+ #!/usr/bin/env node
2
+ export {};
package/lib/index.js CHANGED
@@ -1,2 +1,125 @@
1
- export * from './abi.js';
1
+ #!/usr/bin/env node
2
+ import commandLineArgs from 'command-line-args';
3
+ import commandLineUsage from 'command-line-usage';
4
+ import fs from 'fs';
5
+ import path from 'path';
6
+ import yaml from 'yaml';
7
+ import chalk from 'chalk';
8
+ import { buildProcessorWithArgs, generate } from './commands/build.js';
9
+ import { runCreate } from './commands/run-create.js';
10
+ import { runVersion } from './commands/run-version.js';
11
+ import { runLogin } from './commands/run-login.js';
12
+ import { runUpload } from './commands/run-upload.js';
13
+ import { runTest } from './commands/run-test.js';
14
+ import { runAdd } from './commands/run-add.js';
15
+ const mainDefinitions = [{ name: 'command', defaultOption: true }];
16
+ const mainOptions = commandLineArgs(mainDefinitions, {
17
+ stopAtFirstUnknown: true,
18
+ });
19
+ const argv = mainOptions._unknown || [];
20
+ if (!mainOptions.command) {
21
+ usage();
22
+ }
23
+ if (mainOptions.command === 'login') {
24
+ runLogin(argv);
25
+ }
26
+ else if (mainOptions.command === 'create') {
27
+ await runCreate(argv);
28
+ }
29
+ else if (mainOptions.command === 'version') {
30
+ runVersion(argv);
31
+ }
32
+ else if (mainOptions.command === 'test') {
33
+ runTest(argv);
34
+ }
35
+ else if (mainOptions.command === 'add') {
36
+ await runAdd(argv);
37
+ }
38
+ else {
39
+ // For all the commands that need read project configs
40
+ // TODO move them to their own modules
41
+ // Process configs
42
+ let processorConfig = { host: '', project: '', build: true, debug: false, contracts: [] };
43
+ // Fist step, read from project yaml file
44
+ try {
45
+ console.log(chalk.blue('Loading Process config'));
46
+ // TODO correctly located sentio.yaml
47
+ const pwd = process.cwd();
48
+ const packageJson = path.join(pwd, 'package.json');
49
+ if (!fs.existsSync(packageJson)) {
50
+ console.error('package.json not found, please run this command in the root of your project');
51
+ process.exit(1);
52
+ }
53
+ const yamlPath = path.join(pwd, 'sentio.yaml');
54
+ if (!fs.existsSync(yamlPath)) {
55
+ console.error('sentio.yaml not found, please create one according to: TODO docs');
56
+ process.exit(1);
57
+ }
58
+ processorConfig = yaml.parse(fs.readFileSync('sentio.yaml', 'utf8'));
59
+ if (!processorConfig.project === undefined) {
60
+ console.error('Config yaml must have contain a valid project identifier');
61
+ process.exit(1);
62
+ }
63
+ if (processorConfig.build === undefined) {
64
+ processorConfig.build = true;
65
+ }
66
+ if (!processorConfig.host) {
67
+ processorConfig.host = 'prod';
68
+ }
69
+ if (processorConfig.debug === undefined) {
70
+ processorConfig.debug = false;
71
+ }
72
+ // if (!processorConfig.source) {
73
+ // processorConfig.source = 'src/processor.ts'
74
+ // }
75
+ // if (!processorConfig.targets) {
76
+ // console.warn('targets is not defined, use EVM as the default target')
77
+ // processorConfig.targets = []
78
+ // }
79
+ // if (processorConfig.targets.length === 0) {
80
+ // // By default evm
81
+ // processorConfig.targets.push({ chain: EVM })
82
+ // }
83
+ }
84
+ catch (e) {
85
+ console.error(e);
86
+ process.exit(1);
87
+ }
88
+ if (mainOptions.command === 'upload') {
89
+ await runUpload(processorConfig, argv);
90
+ }
91
+ else if (mainOptions.command === 'build') {
92
+ await buildProcessorWithArgs(argv);
93
+ }
94
+ else if (mainOptions.command === 'gen') {
95
+ await generate(argv);
96
+ }
97
+ else {
98
+ usage();
99
+ }
100
+ }
101
+ function usage() {
102
+ const usage = commandLineUsage([
103
+ {
104
+ header: 'Sentio',
105
+ content: 'Login & Manage your project files to Sentio.',
106
+ },
107
+ {
108
+ header: 'Usage',
109
+ content: [
110
+ 'sentio <command> --help\t\tshow detail usage of specific command',
111
+ 'sentio login\t\t\t\tlogin to sentio',
112
+ 'sentio create\t\t\t\tcreate a template project',
113
+ 'sentio add\t\t\t\tadd contract ABI to the project',
114
+ 'sentio upload\t\t\t\tbuild and upload processor to sentio',
115
+ 'sentio gen\t\t\t\tgenerate abi',
116
+ 'sentio build\t\t\t\tgenerate abi and build',
117
+ 'sentio test\t\t\t\trun tests',
118
+ 'sentio version\t\t\tcurrent cli version',
119
+ ],
120
+ },
121
+ ]);
122
+ console.log(usage);
123
+ process.exit(1);
124
+ }
2
125
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA","sourcesContent":["export * from './abi.js'\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,eAAe,MAAM,mBAAmB,CAAA;AAC/C,OAAO,gBAAgB,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAAE,MAAM,IAAI,CAAA;AACnB,OAAO,IAAI,MAAM,MAAM,CAAA;AAEvB,OAAO,IAAI,MAAM,MAAM,CAAA;AAEvB,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,sBAAsB,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AACtE,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAE9C,MAAM,eAAe,GAAG,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAA;AAClE,MAAM,WAAW,GAAG,eAAe,CAAC,eAAe,EAAE;IACnD,kBAAkB,EAAE,IAAI;CACzB,CAAC,CAAA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MAAM,sBAAsB,CAAC,IAAI,CAAC,CAAA;KACnC;SAAM,IAAI,WAAW,CAAC,OAAO,KAAK,KAAK,EAAE;QACxC,MAAM,QAAQ,CAAC,IAAI,CAAC,CAAA;KACrB;SAAM;QACL,KAAK,EAAE,CAAA;KACR;CACF;AAED,SAAS,KAAK;IACZ,MAAM,KAAK,GAAG,gBAAgB,CAAC;QAC7B;YACE,MAAM,EAAE,QAAQ;YAChB,OAAO,EAAE,8CAA8C;SACxD;QACD;YACE,MAAM,EAAE,OAAO;YACf,OAAO,EAAE;gBACP,kEAAkE;gBAClE,qCAAqC;gBACrC,gDAAgD;gBAChD,mDAAmD;gBACnD,2DAA2D;gBAC3D,gCAAgC;gBAChC,4CAA4C;gBAC5C,8BAA8B;gBAC9B,yCAAyC;aAC1C;SACF;KACF,CAAC,CAAA;IACF,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;IAClB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC","sourcesContent":["#!/usr/bin/env node\n\nimport commandLineArgs from 'command-line-args'\nimport commandLineUsage from 'command-line-usage'\nimport fs from 'fs'\nimport path from 'path'\n\nimport yaml from 'yaml'\nimport { YamlProjectConfig } from './config.js'\nimport chalk from 'chalk'\nimport { buildProcessorWithArgs, generate } from './commands/build.js'\nimport { runCreate } from './commands/run-create.js'\nimport { runVersion } from './commands/run-version.js'\nimport { runLogin } from './commands/run-login.js'\nimport { runUpload } from './commands/run-upload.js'\nimport { runTest } from './commands/run-test.js'\nimport { runAdd } from './commands/run-add.js'\n\nconst mainDefinitions = [{ name: 'command', defaultOption: true }]\nconst mainOptions = commandLineArgs(mainDefinitions, {\n stopAtFirstUnknown: true,\n})\nconst argv = mainOptions._unknown || []\n\nif (!mainOptions.command) {\n usage()\n}\n\nif (mainOptions.command === 'login') {\n runLogin(argv)\n} else if (mainOptions.command === 'create') {\n await runCreate(argv)\n} else if (mainOptions.command === 'version') {\n runVersion(argv)\n} else if (mainOptions.command === 'test') {\n runTest(argv)\n} else if (mainOptions.command === 'add') {\n await runAdd(argv)\n} else {\n // For all the commands that need read project configs\n // TODO move them to their own modules\n\n // Process configs\n let processorConfig: YamlProjectConfig = { host: '', project: '', build: true, debug: false, contracts: [] }\n // Fist step, read from project yaml file\n try {\n console.log(chalk.blue('Loading Process config'))\n // TODO correctly located sentio.yaml\n const pwd = process.cwd()\n const packageJson = path.join(pwd, 'package.json')\n if (!fs.existsSync(packageJson)) {\n console.error('package.json not found, please run this command in the root of your project')\n process.exit(1)\n }\n\n const yamlPath = path.join(pwd, 'sentio.yaml')\n if (!fs.existsSync(yamlPath)) {\n console.error('sentio.yaml not found, please create one according to: TODO docs')\n process.exit(1)\n }\n\n processorConfig = yaml.parse(fs.readFileSync('sentio.yaml', 'utf8')) as YamlProjectConfig\n if (!processorConfig.project === undefined) {\n console.error('Config yaml must have contain a valid project identifier')\n process.exit(1)\n }\n if (processorConfig.build === undefined) {\n processorConfig.build = true\n }\n if (!processorConfig.host) {\n processorConfig.host = 'prod'\n }\n if (processorConfig.debug === undefined) {\n processorConfig.debug = false\n }\n\n // if (!processorConfig.source) {\n // processorConfig.source = 'src/processor.ts'\n // }\n // if (!processorConfig.targets) {\n // console.warn('targets is not defined, use EVM as the default target')\n // processorConfig.targets = []\n // }\n // if (processorConfig.targets.length === 0) {\n // // By default evm\n // processorConfig.targets.push({ chain: EVM })\n // }\n } catch (e) {\n console.error(e)\n process.exit(1)\n }\n\n if (mainOptions.command === 'upload') {\n await runUpload(processorConfig, argv)\n } else if (mainOptions.command === 'build') {\n await buildProcessorWithArgs(argv)\n } else if (mainOptions.command === 'gen') {\n await generate(argv)\n } else {\n usage()\n }\n}\n\nfunction usage() {\n const usage = commandLineUsage([\n {\n header: 'Sentio',\n content: 'Login & Manage your project files to Sentio.',\n },\n {\n header: 'Usage',\n content: [\n 'sentio <command> --help\\t\\tshow detail usage of specific command',\n 'sentio login\\t\\t\\t\\tlogin to sentio',\n 'sentio create\\t\\t\\t\\tcreate a template project',\n 'sentio add\\t\\t\\t\\tadd contract ABI to the project',\n 'sentio upload\\t\\t\\t\\tbuild and upload processor to sentio',\n 'sentio gen\\t\\t\\t\\tgenerate abi',\n 'sentio build\\t\\t\\t\\tgenerate abi and build',\n 'sentio test\\t\\t\\t\\trun tests',\n 'sentio version\\t\\t\\tcurrent cli version',\n ],\n },\n ])\n console.log(usage)\n process.exit(1)\n}\n"]}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@sentio/cli",
3
3
  "license": "Apache-2.0",
4
4
  "type": "module",
5
- "version": "2.7.2",
5
+ "version": "2.7.3",
6
6
  "dependencies": {
7
7
  "@jest/types": "^29.5.0",
8
8
  "@types/jest": "^29.5.0",
@@ -31,11 +31,9 @@
31
31
  "@types/express": "^4.17.14",
32
32
  "@types/fs-extra": "^11.0.1"
33
33
  },
34
- "peerDependencies": {
35
- "@sentio/sdk": "^2.13.4"
36
- },
34
+ "peerDependencies": {},
37
35
  "bin": {
38
- "sentio": "./lib/cli.js"
36
+ "sentio": "./lib/index.js"
39
37
  },
40
38
  "types": "module",
41
39
  "exports": {
@@ -52,7 +50,7 @@
52
50
  "compile": "tsc",
53
51
  "build": "pnpm compile",
54
52
  "postbuild": "pnpm install",
55
- "cli": "ts-node-esm src/cli.ts",
53
+ "cli": "ts-node-esm src/index.ts",
56
54
  "test": "NODE_OPTIONS=--experimental-vm-modules pnpm jest"
57
55
  }
58
56
  }
package/src/index.ts CHANGED
@@ -1 +1,127 @@
1
- export * from './abi.js'
1
+ #!/usr/bin/env node
2
+
3
+ import commandLineArgs from 'command-line-args'
4
+ import commandLineUsage from 'command-line-usage'
5
+ import fs from 'fs'
6
+ import path from 'path'
7
+
8
+ import yaml from 'yaml'
9
+ import { YamlProjectConfig } from './config.js'
10
+ import chalk from 'chalk'
11
+ import { buildProcessorWithArgs, generate } from './commands/build.js'
12
+ import { runCreate } from './commands/run-create.js'
13
+ import { runVersion } from './commands/run-version.js'
14
+ import { runLogin } from './commands/run-login.js'
15
+ import { runUpload } from './commands/run-upload.js'
16
+ import { runTest } from './commands/run-test.js'
17
+ import { runAdd } from './commands/run-add.js'
18
+
19
+ const mainDefinitions = [{ name: 'command', defaultOption: true }]
20
+ const mainOptions = commandLineArgs(mainDefinitions, {
21
+ stopAtFirstUnknown: true,
22
+ })
23
+ const argv = mainOptions._unknown || []
24
+
25
+ if (!mainOptions.command) {
26
+ usage()
27
+ }
28
+
29
+ if (mainOptions.command === 'login') {
30
+ runLogin(argv)
31
+ } else if (mainOptions.command === 'create') {
32
+ await runCreate(argv)
33
+ } else if (mainOptions.command === 'version') {
34
+ runVersion(argv)
35
+ } else if (mainOptions.command === 'test') {
36
+ runTest(argv)
37
+ } else if (mainOptions.command === 'add') {
38
+ await runAdd(argv)
39
+ } else {
40
+ // For all the commands that need read project configs
41
+ // TODO move them to their own modules
42
+
43
+ // Process configs
44
+ let processorConfig: YamlProjectConfig = { host: '', project: '', build: true, debug: false, contracts: [] }
45
+ // Fist step, read from project yaml file
46
+ try {
47
+ console.log(chalk.blue('Loading Process config'))
48
+ // TODO correctly located sentio.yaml
49
+ const pwd = process.cwd()
50
+ const packageJson = path.join(pwd, 'package.json')
51
+ if (!fs.existsSync(packageJson)) {
52
+ console.error('package.json not found, please run this command in the root of your project')
53
+ process.exit(1)
54
+ }
55
+
56
+ const yamlPath = path.join(pwd, 'sentio.yaml')
57
+ if (!fs.existsSync(yamlPath)) {
58
+ console.error('sentio.yaml not found, please create one according to: TODO docs')
59
+ process.exit(1)
60
+ }
61
+
62
+ processorConfig = yaml.parse(fs.readFileSync('sentio.yaml', 'utf8')) as YamlProjectConfig
63
+ if (!processorConfig.project === undefined) {
64
+ console.error('Config yaml must have contain a valid project identifier')
65
+ process.exit(1)
66
+ }
67
+ if (processorConfig.build === undefined) {
68
+ processorConfig.build = true
69
+ }
70
+ if (!processorConfig.host) {
71
+ processorConfig.host = 'prod'
72
+ }
73
+ if (processorConfig.debug === undefined) {
74
+ processorConfig.debug = false
75
+ }
76
+
77
+ // if (!processorConfig.source) {
78
+ // processorConfig.source = 'src/processor.ts'
79
+ // }
80
+ // if (!processorConfig.targets) {
81
+ // console.warn('targets is not defined, use EVM as the default target')
82
+ // processorConfig.targets = []
83
+ // }
84
+ // if (processorConfig.targets.length === 0) {
85
+ // // By default evm
86
+ // processorConfig.targets.push({ chain: EVM })
87
+ // }
88
+ } catch (e) {
89
+ console.error(e)
90
+ process.exit(1)
91
+ }
92
+
93
+ if (mainOptions.command === 'upload') {
94
+ await runUpload(processorConfig, argv)
95
+ } else if (mainOptions.command === 'build') {
96
+ await buildProcessorWithArgs(argv)
97
+ } else if (mainOptions.command === 'gen') {
98
+ await generate(argv)
99
+ } else {
100
+ usage()
101
+ }
102
+ }
103
+
104
+ function usage() {
105
+ const usage = commandLineUsage([
106
+ {
107
+ header: 'Sentio',
108
+ content: 'Login & Manage your project files to Sentio.',
109
+ },
110
+ {
111
+ header: 'Usage',
112
+ content: [
113
+ 'sentio <command> --help\t\tshow detail usage of specific command',
114
+ 'sentio login\t\t\t\tlogin to sentio',
115
+ 'sentio create\t\t\t\tcreate a template project',
116
+ 'sentio add\t\t\t\tadd contract ABI to the project',
117
+ 'sentio upload\t\t\t\tbuild and upload processor to sentio',
118
+ 'sentio gen\t\t\t\tgenerate abi',
119
+ 'sentio build\t\t\t\tgenerate abi and build',
120
+ 'sentio test\t\t\t\trun tests',
121
+ 'sentio version\t\t\tcurrent cli version',
122
+ ],
123
+ },
124
+ ])
125
+ console.log(usage)
126
+ process.exit(1)
127
+ }
package/lib/cli.d.ts DELETED
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
package/lib/cli.js DELETED
@@ -1,125 +0,0 @@
1
- #!/usr/bin/env node
2
- import commandLineArgs from 'command-line-args';
3
- import commandLineUsage from 'command-line-usage';
4
- import fs from 'fs';
5
- import path from 'path';
6
- import yaml from 'yaml';
7
- import chalk from 'chalk';
8
- import { buildProcessorWithArgs, generate } from './commands/build.js';
9
- import { runCreate } from './commands/run-create.js';
10
- import { runVersion } from './commands/run-version.js';
11
- import { runLogin } from './commands/run-login.js';
12
- import { runUpload } from './commands/run-upload.js';
13
- import { runTest } from './commands/run-test.js';
14
- import { runAdd } from './commands/run-add.js';
15
- const mainDefinitions = [{ name: 'command', defaultOption: true }];
16
- const mainOptions = commandLineArgs(mainDefinitions, {
17
- stopAtFirstUnknown: true,
18
- });
19
- const argv = mainOptions._unknown || [];
20
- if (!mainOptions.command) {
21
- usage();
22
- }
23
- if (mainOptions.command === 'login') {
24
- runLogin(argv);
25
- }
26
- else if (mainOptions.command === 'create') {
27
- await runCreate(argv);
28
- }
29
- else if (mainOptions.command === 'version') {
30
- runVersion(argv);
31
- }
32
- else if (mainOptions.command === 'test') {
33
- runTest(argv);
34
- }
35
- else if (mainOptions.command === 'add') {
36
- await runAdd(argv);
37
- }
38
- else {
39
- // For all the commands that need read project configs
40
- // TODO move them to their own modules
41
- // Process configs
42
- let processorConfig = { host: '', project: '', build: true, debug: false, contracts: [] };
43
- // Fist step, read from project yaml file
44
- try {
45
- console.log(chalk.blue('Loading Process config'));
46
- // TODO correctly located sentio.yaml
47
- const pwd = process.cwd();
48
- const packageJson = path.join(pwd, 'package.json');
49
- if (!fs.existsSync(packageJson)) {
50
- console.error('package.json not found, please run this command in the root of your project');
51
- process.exit(1);
52
- }
53
- const yamlPath = path.join(pwd, 'sentio.yaml');
54
- if (!fs.existsSync(yamlPath)) {
55
- console.error('sentio.yaml not found, please create one according to: TODO docs');
56
- process.exit(1);
57
- }
58
- processorConfig = yaml.parse(fs.readFileSync('sentio.yaml', 'utf8'));
59
- if (!processorConfig.project === undefined) {
60
- console.error('Config yaml must have contain a valid project identifier');
61
- process.exit(1);
62
- }
63
- if (processorConfig.build === undefined) {
64
- processorConfig.build = true;
65
- }
66
- if (!processorConfig.host) {
67
- processorConfig.host = 'prod';
68
- }
69
- if (processorConfig.debug === undefined) {
70
- processorConfig.debug = false;
71
- }
72
- // if (!processorConfig.source) {
73
- // processorConfig.source = 'src/processor.ts'
74
- // }
75
- // if (!processorConfig.targets) {
76
- // console.warn('targets is not defined, use EVM as the default target')
77
- // processorConfig.targets = []
78
- // }
79
- // if (processorConfig.targets.length === 0) {
80
- // // By default evm
81
- // processorConfig.targets.push({ chain: EVM })
82
- // }
83
- }
84
- catch (e) {
85
- console.error(e);
86
- process.exit(1);
87
- }
88
- if (mainOptions.command === 'upload') {
89
- await runUpload(processorConfig, argv);
90
- }
91
- else if (mainOptions.command === 'build') {
92
- await buildProcessorWithArgs(argv);
93
- }
94
- else if (mainOptions.command === 'gen') {
95
- await generate(argv);
96
- }
97
- else {
98
- usage();
99
- }
100
- }
101
- function usage() {
102
- const usage = commandLineUsage([
103
- {
104
- header: 'Sentio',
105
- content: 'Login & Manage your project files to Sentio.',
106
- },
107
- {
108
- header: 'Usage',
109
- content: [
110
- 'sentio <command> --help\t\tshow detail usage of specific command',
111
- 'sentio login\t\t\t\tlogin to sentio',
112
- 'sentio create\t\t\t\tcreate a template project',
113
- 'sentio add\t\t\t\tadd contract ABI to the project',
114
- 'sentio upload\t\t\t\tbuild and upload processor to sentio',
115
- 'sentio gen\t\t\t\tgenerate abi',
116
- 'sentio build\t\t\t\tgenerate abi and build',
117
- 'sentio test\t\t\t\trun tests',
118
- 'sentio version\t\t\tcurrent cli version',
119
- ],
120
- },
121
- ]);
122
- console.log(usage);
123
- process.exit(1);
124
- }
125
- //# sourceMappingURL=cli.js.map
package/lib/cli.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA,OAAO,eAAe,MAAM,mBAAmB,CAAA;AAC/C,OAAO,gBAAgB,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAAE,MAAM,IAAI,CAAA;AACnB,OAAO,IAAI,MAAM,MAAM,CAAA;AAEvB,OAAO,IAAI,MAAM,MAAM,CAAA;AAEvB,OAAO,KAAK,MAAM,OAA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'command-line-args'\nimport commandLineUsage from 'command-line-usage'\nimport fs from 'fs'\nimport path from 'path'\n\nimport yaml from 'yaml'\nimport { YamlProjectConfig } from './config.js'\nimport chalk from 'chalk'\nimport { buildProcessorWithArgs, generate } from './commands/build.js'\nimport { runCreate } from './commands/run-create.js'\nimport { runVersion } from './commands/run-version.js'\nimport { runLogin } from './commands/run-login.js'\nimport { runUpload } from './commands/run-upload.js'\nimport { runTest } from './commands/run-test.js'\nimport { runAdd } from './commands/run-add.js'\n\nconst mainDefinitions = [{ name: 'command', defaultOption: true }]\nconst mainOptions = commandLineArgs(mainDefinitions, {\n stopAtFirstUnknown: true,\n})\nconst argv = mainOptions._unknown || []\n\nif (!mainOptions.command) {\n usage()\n}\n\nif (mainOptions.command === 'login') {\n runLogin(argv)\n} else if (mainOptions.command === 'create') {\n await runCreate(argv)\n} else if (mainOptions.command === 'version') {\n runVersion(argv)\n} else if (mainOptions.command === 'test') {\n runTest(argv)\n} else if (mainOptions.command === 'add') {\n await runAdd(argv)\n} else {\n // For all the commands that need read project configs\n // TODO move them to their own modules\n\n // Process configs\n let processorConfig: YamlProjectConfig = { host: '', project: '', build: true, debug: false, contracts: [] }\n // Fist step, read from project yaml file\n try {\n console.log(chalk.blue('Loading Process config'))\n // TODO correctly located sentio.yaml\n const pwd = process.cwd()\n const packageJson = path.join(pwd, 'package.json')\n if (!fs.existsSync(packageJson)) {\n console.error('package.json not found, please run this command in the root of your project')\n process.exit(1)\n }\n\n const yamlPath = path.join(pwd, 'sentio.yaml')\n if (!fs.existsSync(yamlPath)) {\n console.error('sentio.yaml not found, please create one according to: TODO docs')\n process.exit(1)\n }\n\n processorConfig = yaml.parse(fs.readFileSync('sentio.yaml', 'utf8')) as YamlProjectConfig\n if (!processorConfig.project === undefined) {\n console.error('Config yaml must have contain a valid project identifier')\n process.exit(1)\n }\n if (processorConfig.build === undefined) {\n processorConfig.build = true\n }\n if (!processorConfig.host) {\n processorConfig.host = 'prod'\n }\n if (processorConfig.debug === undefined) {\n processorConfig.debug = false\n }\n\n // if (!processorConfig.source) {\n // processorConfig.source = 'src/processor.ts'\n // }\n // if (!processorConfig.targets) {\n // console.warn('targets is not defined, use EVM as the default target')\n // processorConfig.targets = []\n // }\n // if (processorConfig.targets.length === 0) {\n // // By default evm\n // processorConfig.targets.push({ chain: EVM })\n // }\n } catch (e) {\n console.error(e)\n process.exit(1)\n }\n\n if (mainOptions.command === 'upload') {\n await runUpload(processorConfig, argv)\n } else if (mainOptions.command === 'build') {\n await buildProcessorWithArgs(argv)\n } else if (mainOptions.command === 'gen') {\n await generate(argv)\n } else {\n usage()\n }\n}\n\nfunction usage() {\n const usage = commandLineUsage([\n {\n header: 'Sentio',\n content: 'Login & Manage your project files to Sentio.',\n },\n {\n header: 'Usage',\n content: [\n 'sentio <command> --help\\t\\tshow detail usage of specific command',\n 'sentio login\\t\\t\\t\\tlogin to sentio',\n 'sentio create\\t\\t\\t\\tcreate a template project',\n 'sentio add\\t\\t\\t\\tadd contract ABI to the project',\n 'sentio upload\\t\\t\\t\\tbuild and upload processor to sentio',\n 'sentio gen\\t\\t\\t\\tgenerate abi',\n 'sentio build\\t\\t\\t\\tgenerate abi and build',\n 'sentio test\\t\\t\\t\\trun tests',\n 'sentio version\\t\\t\\tcurrent cli version',\n ],\n },\n ])\n console.log(usage)\n process.exit(1)\n}\n"]}
package/src/cli.ts DELETED
@@ -1,127 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import commandLineArgs from 'command-line-args'
4
- import commandLineUsage from 'command-line-usage'
5
- import fs from 'fs'
6
- import path from 'path'
7
-
8
- import yaml from 'yaml'
9
- import { YamlProjectConfig } from './config.js'
10
- import chalk from 'chalk'
11
- import { buildProcessorWithArgs, generate } from './commands/build.js'
12
- import { runCreate } from './commands/run-create.js'
13
- import { runVersion } from './commands/run-version.js'
14
- import { runLogin } from './commands/run-login.js'
15
- import { runUpload } from './commands/run-upload.js'
16
- import { runTest } from './commands/run-test.js'
17
- import { runAdd } from './commands/run-add.js'
18
-
19
- const mainDefinitions = [{ name: 'command', defaultOption: true }]
20
- const mainOptions = commandLineArgs(mainDefinitions, {
21
- stopAtFirstUnknown: true,
22
- })
23
- const argv = mainOptions._unknown || []
24
-
25
- if (!mainOptions.command) {
26
- usage()
27
- }
28
-
29
- if (mainOptions.command === 'login') {
30
- runLogin(argv)
31
- } else if (mainOptions.command === 'create') {
32
- await runCreate(argv)
33
- } else if (mainOptions.command === 'version') {
34
- runVersion(argv)
35
- } else if (mainOptions.command === 'test') {
36
- runTest(argv)
37
- } else if (mainOptions.command === 'add') {
38
- await runAdd(argv)
39
- } else {
40
- // For all the commands that need read project configs
41
- // TODO move them to their own modules
42
-
43
- // Process configs
44
- let processorConfig: YamlProjectConfig = { host: '', project: '', build: true, debug: false, contracts: [] }
45
- // Fist step, read from project yaml file
46
- try {
47
- console.log(chalk.blue('Loading Process config'))
48
- // TODO correctly located sentio.yaml
49
- const pwd = process.cwd()
50
- const packageJson = path.join(pwd, 'package.json')
51
- if (!fs.existsSync(packageJson)) {
52
- console.error('package.json not found, please run this command in the root of your project')
53
- process.exit(1)
54
- }
55
-
56
- const yamlPath = path.join(pwd, 'sentio.yaml')
57
- if (!fs.existsSync(yamlPath)) {
58
- console.error('sentio.yaml not found, please create one according to: TODO docs')
59
- process.exit(1)
60
- }
61
-
62
- processorConfig = yaml.parse(fs.readFileSync('sentio.yaml', 'utf8')) as YamlProjectConfig
63
- if (!processorConfig.project === undefined) {
64
- console.error('Config yaml must have contain a valid project identifier')
65
- process.exit(1)
66
- }
67
- if (processorConfig.build === undefined) {
68
- processorConfig.build = true
69
- }
70
- if (!processorConfig.host) {
71
- processorConfig.host = 'prod'
72
- }
73
- if (processorConfig.debug === undefined) {
74
- processorConfig.debug = false
75
- }
76
-
77
- // if (!processorConfig.source) {
78
- // processorConfig.source = 'src/processor.ts'
79
- // }
80
- // if (!processorConfig.targets) {
81
- // console.warn('targets is not defined, use EVM as the default target')
82
- // processorConfig.targets = []
83
- // }
84
- // if (processorConfig.targets.length === 0) {
85
- // // By default evm
86
- // processorConfig.targets.push({ chain: EVM })
87
- // }
88
- } catch (e) {
89
- console.error(e)
90
- process.exit(1)
91
- }
92
-
93
- if (mainOptions.command === 'upload') {
94
- await runUpload(processorConfig, argv)
95
- } else if (mainOptions.command === 'build') {
96
- await buildProcessorWithArgs(argv)
97
- } else if (mainOptions.command === 'gen') {
98
- await generate(argv)
99
- } else {
100
- usage()
101
- }
102
- }
103
-
104
- function usage() {
105
- const usage = commandLineUsage([
106
- {
107
- header: 'Sentio',
108
- content: 'Login & Manage your project files to Sentio.',
109
- },
110
- {
111
- header: 'Usage',
112
- content: [
113
- 'sentio <command> --help\t\tshow detail usage of specific command',
114
- 'sentio login\t\t\t\tlogin to sentio',
115
- 'sentio create\t\t\t\tcreate a template project',
116
- 'sentio add\t\t\t\tadd contract ABI to the project',
117
- 'sentio upload\t\t\t\tbuild and upload processor to sentio',
118
- 'sentio gen\t\t\t\tgenerate abi',
119
- 'sentio build\t\t\t\tgenerate abi and build',
120
- 'sentio test\t\t\t\trun tests',
121
- 'sentio version\t\t\tcurrent cli version',
122
- ],
123
- },
124
- ])
125
- console.log(usage)
126
- process.exit(1)
127
- }