@sentio/cli 1.37.5-rc.6 → 2.0.0-development
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.js +125 -0
- package/package.json +42 -41
- package/lib/build.d.ts +0 -2
- package/lib/build.js +0 -86
- package/lib/build.js.map +0 -1
- package/lib/cli.d.ts +0 -2
- package/lib/cli.js +0 -186
- package/lib/cli.js.map +0 -1
- package/lib/commands/login-server.d.ts +0 -7
- package/lib/commands/login-server.js +0 -133
- package/lib/commands/login-server.js.map +0 -1
- package/lib/commands/run-create.d.ts +0 -1
- package/lib/commands/run-create.js +0 -121
- package/lib/commands/run-create.js.map +0 -1
- package/lib/commands/run-login.d.ts +0 -1
- package/lib/commands/run-login.js +0 -136
- package/lib/commands/run-login.js.map +0 -1
- package/lib/commands/run-version.d.ts +0 -1
- package/lib/commands/run-version.js +0 -69
- package/lib/commands/run-version.js.map +0 -1
- package/lib/config.d.ts +0 -14
- package/lib/config.js +0 -64
- package/lib/config.js.map +0 -1
- package/lib/key.d.ts +0 -2
- package/lib/key.js +0 -44
- package/lib/key.js.map +0 -1
- package/lib/upload.d.ts +0 -2
- package/lib/upload.js +0 -189
- package/lib/upload.js.map +0 -1
- package/lib/utils.d.ts +0 -2
- package/lib/utils.js +0 -28
- package/lib/utils.js.map +0 -1
- package/lib/webpack.config.js +0 -50
- package/src/build.ts +0 -99
- package/src/cli.ts +0 -184
- package/src/commands/login-server.ts +0 -119
- package/src/commands/run-create.ts +0 -126
- package/src/commands/run-login.ts +0 -111
- package/src/commands/run-version.ts +0 -38
- package/src/config.ts +0 -72
- package/src/key.ts +0 -43
- package/src/upload.ts +0 -214
- package/src/utils.ts +0 -21
- package/src/webpack.config.js +0 -50
- package/templates/aptos/abis/aptos/souffle.json +0 -389
- package/templates/aptos/jest.config.js +0 -7
- package/templates/aptos/package.json +0 -21
- package/templates/aptos/sentio.yaml +0 -1
- package/templates/aptos/src/processor.ts +0 -13
- package/templates/aptos/tsconfig.json +0 -20
- package/templates/evm/abis/evm/x2y2.json +0 -296
- package/templates/evm/jest.config.js +0 -7
- package/templates/evm/package.json +0 -20
- package/templates/evm/sentio.yaml +0 -3
- package/templates/evm/src/processor.ts +0 -29
- package/templates/evm/tsconfig.json +0 -20
- package/templates/raw/jest.config.js +0 -7
- package/templates/raw/package.json +0 -20
- package/templates/raw/sentio.yaml +0 -3
- package/templates/raw/src/processor.ts +0 -0
- package/templates/raw/tsconfig.json +0 -20
- package/templates/raw/yarn.lock +0 -4095
- package/templates/solana/jest.config.js +0 -7
- package/templates/solana/package.json +0 -21
- package/templates/solana/sentio.yaml +0 -3
- package/templates/solana/src/processor.ts +0 -16
- package/templates/solana/tsconfig.json +0 -20
- package/templates/solana/yarn.lock +0 -4918
package/lib/index.js
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
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=index.js.map
|
package/package.json
CHANGED
|
@@ -1,59 +1,60 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentio/cli",
|
|
3
|
+
"version": "2.0.0-development",
|
|
3
4
|
"license": "Apache-2.0",
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
"
|
|
10
|
-
"cli": "ts-node src/cli.ts",
|
|
11
|
-
"test": "jest",
|
|
12
|
-
"pub": "yarn build && yarn publish --no-git-tag-version"
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": "./lib/index.js"
|
|
8
|
+
},
|
|
9
|
+
"bin": {
|
|
10
|
+
"sentio": "./lib/index.js"
|
|
13
11
|
},
|
|
12
|
+
"files": [
|
|
13
|
+
"{lib,src,templates}",
|
|
14
|
+
"!{lib,src}/**/*.test.{js,ts}"
|
|
15
|
+
],
|
|
16
|
+
"types": "module",
|
|
14
17
|
"dependencies": {
|
|
15
|
-
"
|
|
18
|
+
"@jest/globals": "^29.5.0",
|
|
19
|
+
"@jest/types": "^29.5.0",
|
|
20
|
+
"@mysten/sui.js": "^0.44.0",
|
|
21
|
+
"@sentio/chain": "^1.0.3",
|
|
22
|
+
"@types/jest": "^29.5.0",
|
|
23
|
+
"@types/node": "^18.11.18",
|
|
24
|
+
"aptos": "^1.17.0",
|
|
25
|
+
"chalk": "^5.2.0",
|
|
16
26
|
"command-line-args": "^5.2.1",
|
|
17
|
-
"command-line-usage": "^
|
|
27
|
+
"command-line-usage": "^7.0.1",
|
|
18
28
|
"express": "^4.18.2",
|
|
19
29
|
"form-data": "^4.0.0",
|
|
20
30
|
"fs-extra": "^11.0.0",
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
31
|
+
"jest": "^29.5.0",
|
|
32
|
+
"jszip": "^3.10.1",
|
|
33
|
+
"latest-version": "^7.0.0",
|
|
34
|
+
"node-fetch": "^3.3.0",
|
|
35
|
+
"open": "^9.0.0",
|
|
36
|
+
"ts-jest": "^29.1.0",
|
|
37
|
+
"ts-node": "^10.9.1",
|
|
38
|
+
"tsup": "npm:@sentio/tsup@^6.7.0",
|
|
39
|
+
"yaml": "^2.2.1"
|
|
40
|
+
},
|
|
41
|
+
"peerDependencies": {
|
|
42
|
+
"@sentio/sdk": "^2.26.1"
|
|
28
43
|
},
|
|
29
44
|
"devDependencies": {
|
|
30
|
-
"@types/chai": "^4.3.1",
|
|
31
45
|
"@types/command-line-args": "^5.2.0",
|
|
32
46
|
"@types/command-line-usage": "^5.0.2",
|
|
33
|
-
"@types/expect": "^24.3.0",
|
|
34
47
|
"@types/express": "^4.17.14",
|
|
35
|
-
"@types/fs-extra": "^
|
|
36
|
-
"@types/js-yaml": "^4.0.5",
|
|
37
|
-
"@types/node": "^18.0.4",
|
|
38
|
-
"@types/node-fetch": "^2.6.2",
|
|
39
|
-
"chai": "^4.3.6",
|
|
40
|
-
"jest": "^29.0.3",
|
|
41
|
-
"ts-jest": "^29.0.3",
|
|
42
|
-
"ts-node": "^10.9.1"
|
|
48
|
+
"@types/fs-extra": "^11.0.1"
|
|
43
49
|
},
|
|
44
|
-
"bin": {
|
|
45
|
-
"sentio": "./lib/cli.js"
|
|
46
|
-
},
|
|
47
|
-
"main": "./lib/index.js",
|
|
48
|
-
"types": "./lib/index.d.ts",
|
|
49
|
-
"module": "./lib/index.js",
|
|
50
|
-
"files": [
|
|
51
|
-
"{lib,src,templates}",
|
|
52
|
-
"!{lib,src}/tests",
|
|
53
|
-
"!**/*.test.{js,ts}"
|
|
54
|
-
],
|
|
55
50
|
"engines": {
|
|
56
51
|
"node": ">=16"
|
|
57
52
|
},
|
|
58
|
-
"
|
|
59
|
-
|
|
53
|
+
"scripts": {
|
|
54
|
+
"build": "pnpm compile",
|
|
55
|
+
"postbuild": "pnpm install",
|
|
56
|
+
"cli": "ts-node-esm src/index.ts",
|
|
57
|
+
"compile": "tsc",
|
|
58
|
+
"test": "NODE_OPTIONS=--experimental-vm-modules pnpm jest"
|
|
59
|
+
}
|
|
60
|
+
}
|
package/lib/build.d.ts
DELETED
package/lib/build.js
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.codeGenEthersProcessor = exports.buildProcessor = void 0;
|
|
7
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
-
const path_1 = __importDefault(require("path"));
|
|
9
|
-
const fs_1 = __importDefault(require("fs"));
|
|
10
|
-
const child_process_1 = require("child_process");
|
|
11
|
-
async function buildProcessor(onlyGen) {
|
|
12
|
-
if (!onlyGen) {
|
|
13
|
-
await installDeps();
|
|
14
|
-
}
|
|
15
|
-
// targets.forEach(async (target) => await buildProcessorForTarget(onlyGen, target))
|
|
16
|
-
// for (const target) {
|
|
17
|
-
await buildProcessorForTarget(onlyGen);
|
|
18
|
-
// }
|
|
19
|
-
if (!onlyGen) {
|
|
20
|
-
const WEBPACK_CONFIG = path_1.default.join(__dirname, 'webpack.config.js');
|
|
21
|
-
await execStep('yarn tsc -p .', 'Compile');
|
|
22
|
-
await execStep('yarn webpack --config=' + WEBPACK_CONFIG, 'Packaging');
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
exports.buildProcessor = buildProcessor;
|
|
26
|
-
async function buildProcessorForTarget(onlyGen) {
|
|
27
|
-
await codeGenEthersProcessor(path_1.default.join('abis', 'evm'));
|
|
28
|
-
try {
|
|
29
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
30
|
-
const solanaModule = require('@sentio/sdk-solana/lib/codegen/codegen');
|
|
31
|
-
solanaModule.codeGenSolanaProcessor(path_1.default.join('abis', 'solana'));
|
|
32
|
-
}
|
|
33
|
-
catch (e) { }
|
|
34
|
-
try {
|
|
35
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
36
|
-
const aptosModuole = require('@sentio/sdk-aptos/lib/codegen/codegen');
|
|
37
|
-
aptosModuole.codeGenAptosProcessor(path_1.default.join('abis', 'aptos'));
|
|
38
|
-
}
|
|
39
|
-
catch (e) { }
|
|
40
|
-
if (onlyGen) {
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
async function installDeps() {
|
|
45
|
-
await execStep('yarn install --ignore-scripts', 'Yarn Install');
|
|
46
|
-
}
|
|
47
|
-
async function codeGenEthersProcessor(abisDir, ETHERS_TARGET = path_1.default.dirname(require.resolve('@sentio/sdk/lib/target-ethers-sentio')), outDir = 'src/types/internal') {
|
|
48
|
-
if (!fs_1.default.existsSync(abisDir)) {
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
let haveJson = false;
|
|
52
|
-
const files = fs_1.default.readdirSync(abisDir);
|
|
53
|
-
for (const file of files) {
|
|
54
|
-
if (file.toLowerCase().endsWith('.json')) {
|
|
55
|
-
haveJson = true;
|
|
56
|
-
break;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
if (!haveJson) {
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
console.log(chalk_1.default.green('Generated Types for EVM'));
|
|
63
|
-
// TODO this will fail during postinstall, need to locate real typechain path
|
|
64
|
-
await execStep('yarn typechain --target ' + ETHERS_TARGET + ` --out-dir ${outDir} ${path_1.default.join(abisDir, '*.json')}`, 'Type definitions gen');
|
|
65
|
-
}
|
|
66
|
-
exports.codeGenEthersProcessor = codeGenEthersProcessor;
|
|
67
|
-
async function execStep(cmd, stepName) {
|
|
68
|
-
const child = (0, child_process_1.exec)(cmd);
|
|
69
|
-
console.log(chalk_1.default.blue(stepName + ' begin'));
|
|
70
|
-
if (!child.stdout || !child.stderr) {
|
|
71
|
-
console.error(chalk_1.default.red(stepName + ' failed'));
|
|
72
|
-
process.exit(1);
|
|
73
|
-
}
|
|
74
|
-
child.stdout.pipe(process.stdout);
|
|
75
|
-
child.stderr.pipe(process.stderr);
|
|
76
|
-
await new Promise((resolve) => {
|
|
77
|
-
child.on('close', resolve);
|
|
78
|
-
});
|
|
79
|
-
if (child.exitCode) {
|
|
80
|
-
console.error(chalk_1.default.red(stepName + ' failed'));
|
|
81
|
-
process.exit(child.exitCode);
|
|
82
|
-
}
|
|
83
|
-
console.log(chalk_1.default.blue(stepName + ' success'));
|
|
84
|
-
console.log();
|
|
85
|
-
}
|
|
86
|
-
//# sourceMappingURL=build.js.map
|
package/lib/build.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"build.js","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":";;;;;;AAAA,kDAAyB;AACzB,gDAAuB;AACvB,4CAAmB;AACnB,iDAAoC;AAE7B,KAAK,UAAU,cAAc,CAAC,OAAgB;IACnD,IAAI,CAAC,OAAO,EAAE;QACZ,MAAM,WAAW,EAAE,CAAA;KACpB;IAED,oFAAoF;IACpF,uBAAuB;IACvB,MAAM,uBAAuB,CAAC,OAAO,CAAC,CAAA;IACtC,IAAI;IAEJ,IAAI,CAAC,OAAO,EAAE;QACZ,MAAM,cAAc,GAAG,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAA;QAChE,MAAM,QAAQ,CAAC,eAAe,EAAE,SAAS,CAAC,CAAA;QAC1C,MAAM,QAAQ,CAAC,wBAAwB,GAAG,cAAc,EAAE,WAAW,CAAC,CAAA;KACvE;AACH,CAAC;AAfD,wCAeC;AAED,KAAK,UAAU,uBAAuB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,UAAU,CAAC,CAAC,CAAA;IAC9C,OAAO,CAAC,GAAG,EAAE,CAAA;AACf,CAAC","sourcesContent":["import chalk from 'chalk'\nimport path from 'path'\nimport fs from 'fs'\nimport { exec } from 'child_process'\n\nexport async function buildProcessor(onlyGen: boolean) {\n if (!onlyGen) {\n await installDeps()\n }\n\n // targets.forEach(async (target) => await buildProcessorForTarget(onlyGen, target))\n // for (const target) {\n await buildProcessorForTarget(onlyGen)\n // }\n\n if (!onlyGen) {\n const WEBPACK_CONFIG = path.join(__dirname, 'webpack.config.js')\n await execStep('yarn tsc -p .', 'Compile')\n await execStep('yarn webpack --config=' + WEBPACK_CONFIG, 'Packaging')\n }\n}\n\nasync function buildProcessorForTarget(onlyGen: boolean) {\n await codeGenEthersProcessor(path.join('abis', 'evm'))\n\n try {\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const solanaModule = require('@sentio/sdk-solana/lib/codegen/codegen')\n solanaModule.codeGenSolanaProcessor(path.join('abis', 'solana'))\n } catch (e) {}\n\n try {\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const aptosModuole = require('@sentio/sdk-aptos/lib/codegen/codegen')\n aptosModuole.codeGenAptosProcessor(path.join('abis', 'aptos'))\n } catch (e) {}\n\n if (onlyGen) {\n return\n }\n}\n\nasync function installDeps() {\n await execStep('yarn install --ignore-scripts', 'Yarn Install')\n}\n\nexport async function codeGenEthersProcessor(\n abisDir: string,\n ETHERS_TARGET = path.dirname(require.resolve('@sentio/sdk/lib/target-ethers-sentio')),\n outDir = 'src/types/internal'\n) {\n if (!fs.existsSync(abisDir)) {\n return\n }\n\n let haveJson = false\n const files = fs.readdirSync(abisDir)\n for (const file of files) {\n if (file.toLowerCase().endsWith('.json')) {\n haveJson = true\n break\n }\n }\n if (!haveJson) {\n return\n }\n\n console.log(chalk.green('Generated Types for EVM'))\n\n // TODO this will fail during postinstall, need to locate real typechain path\n await execStep(\n 'yarn typechain --target ' + ETHERS_TARGET + ` --out-dir ${outDir} ${path.join(abisDir, '*.json')}`,\n 'Type definitions gen'\n )\n}\n\nasync function execStep(cmd: string, stepName: string) {\n const child = exec(cmd)\n console.log(chalk.blue(stepName + ' begin'))\n\n if (!child.stdout || !child.stderr) {\n console.error(chalk.red(stepName + ' failed'))\n process.exit(1)\n }\n\n child.stdout.pipe(process.stdout)\n child.stderr.pipe(process.stderr)\n\n await new Promise((resolve) => {\n child.on('close', resolve)\n })\n\n if (child.exitCode) {\n console.error(chalk.red(stepName + ' failed'))\n process.exit(child.exitCode)\n }\n console.log(chalk.blue(stepName + ' success'))\n console.log()\n}\n"]}
|
package/lib/cli.d.ts
DELETED
package/lib/cli.js
DELETED
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
-
};
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
const command_line_args_1 = __importDefault(require("command-line-args"));
|
|
8
|
-
const command_line_usage_1 = __importDefault(require("command-line-usage"));
|
|
9
|
-
const fs_1 = __importDefault(require("fs"));
|
|
10
|
-
const path_1 = __importDefault(require("path"));
|
|
11
|
-
const js_yaml_1 = __importDefault(require("js-yaml"));
|
|
12
|
-
const config_1 = require("./config");
|
|
13
|
-
const upload_1 = require("./upload");
|
|
14
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
15
|
-
const build_1 = require("./build");
|
|
16
|
-
const run_create_1 = require("./commands/run-create");
|
|
17
|
-
const run_version_1 = require("./commands/run-version");
|
|
18
|
-
const run_login_1 = require("./commands/run-login");
|
|
19
|
-
const mainDefinitions = [{ name: 'command', defaultOption: true }];
|
|
20
|
-
const mainOptions = (0, command_line_args_1.default)(mainDefinitions, {
|
|
21
|
-
stopAtFirstUnknown: true,
|
|
22
|
-
});
|
|
23
|
-
const argv = mainOptions._unknown || [];
|
|
24
|
-
if (!mainOptions.command) {
|
|
25
|
-
usage();
|
|
26
|
-
}
|
|
27
|
-
if (mainOptions.command === 'login') {
|
|
28
|
-
(0, run_login_1.runLogin)(argv);
|
|
29
|
-
}
|
|
30
|
-
else if (mainOptions.command === 'create') {
|
|
31
|
-
(0, run_create_1.runCreate)(argv);
|
|
32
|
-
}
|
|
33
|
-
else if (mainOptions.command === 'version') {
|
|
34
|
-
(0, run_version_1.runVersion)(argv);
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
// For all the commands that need read project configs
|
|
38
|
-
// TODO move them to their own modules
|
|
39
|
-
// Process configs
|
|
40
|
-
let processorConfig = { host: '', project: '', build: true, debug: false };
|
|
41
|
-
// Fist step, read from project yaml file
|
|
42
|
-
try {
|
|
43
|
-
console.log(chalk_1.default.blue('Loading Process config'));
|
|
44
|
-
// TODO correctly located sentio.yaml
|
|
45
|
-
const pwd = process.cwd();
|
|
46
|
-
const packageJson = path_1.default.join(pwd, 'package.json');
|
|
47
|
-
if (!fs_1.default.existsSync(packageJson)) {
|
|
48
|
-
console.error('package.json not found, please run this command in the root of your project');
|
|
49
|
-
process.exit(1);
|
|
50
|
-
}
|
|
51
|
-
const yamlPath = path_1.default.join(pwd, 'sentio.yaml');
|
|
52
|
-
if (!fs_1.default.existsSync(yamlPath)) {
|
|
53
|
-
console.error('sentio.yaml not found, please create one according to: TODO docs');
|
|
54
|
-
process.exit(1);
|
|
55
|
-
}
|
|
56
|
-
processorConfig = js_yaml_1.default.load(fs_1.default.readFileSync('sentio.yaml', 'utf8'));
|
|
57
|
-
if (!processorConfig.project === undefined) {
|
|
58
|
-
console.error('Config yaml must have contain a valid project identifier');
|
|
59
|
-
process.exit(1);
|
|
60
|
-
}
|
|
61
|
-
if (processorConfig.build === undefined) {
|
|
62
|
-
processorConfig.build = true;
|
|
63
|
-
}
|
|
64
|
-
if (!processorConfig.host) {
|
|
65
|
-
processorConfig.host = 'prod';
|
|
66
|
-
}
|
|
67
|
-
if (processorConfig.debug === undefined) {
|
|
68
|
-
processorConfig.debug = false;
|
|
69
|
-
}
|
|
70
|
-
// if (!processorConfig.source) {
|
|
71
|
-
// processorConfig.source = 'src/processor.ts'
|
|
72
|
-
// }
|
|
73
|
-
// if (!processorConfig.targets) {
|
|
74
|
-
// console.warn('targets is not defined, use EVM as the default target')
|
|
75
|
-
// processorConfig.targets = []
|
|
76
|
-
// }
|
|
77
|
-
// if (processorConfig.targets.length === 0) {
|
|
78
|
-
// // By default evm
|
|
79
|
-
// processorConfig.targets.push({ chain: EVM })
|
|
80
|
-
// }
|
|
81
|
-
}
|
|
82
|
-
catch (e) {
|
|
83
|
-
console.error(e);
|
|
84
|
-
process.exit(1);
|
|
85
|
-
}
|
|
86
|
-
if (mainOptions.command === 'upload') {
|
|
87
|
-
const optionDefinitions = [
|
|
88
|
-
{
|
|
89
|
-
name: 'help',
|
|
90
|
-
alias: 'h',
|
|
91
|
-
type: Boolean,
|
|
92
|
-
description: 'Display this usage guide.',
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
name: 'api-key',
|
|
96
|
-
type: String,
|
|
97
|
-
description: '(Optional) Manually provide API key rather than use saved credential',
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
name: 'host',
|
|
101
|
-
description: '(Optional) Override Sentio Host name',
|
|
102
|
-
type: String,
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
name: 'owner',
|
|
106
|
-
description: '(Optional) Override Project owner',
|
|
107
|
-
type: String,
|
|
108
|
-
},
|
|
109
|
-
{
|
|
110
|
-
name: 'nobuild',
|
|
111
|
-
description: '(Optional) Skip build & pack file before uploading, default false',
|
|
112
|
-
type: Boolean,
|
|
113
|
-
},
|
|
114
|
-
{
|
|
115
|
-
name: 'debug',
|
|
116
|
-
description: '(Optional) Set driver logging level to debug',
|
|
117
|
-
type: Boolean,
|
|
118
|
-
},
|
|
119
|
-
];
|
|
120
|
-
const options = (0, command_line_args_1.default)(optionDefinitions, { argv });
|
|
121
|
-
if (options.help) {
|
|
122
|
-
const usage = (0, command_line_usage_1.default)([
|
|
123
|
-
{
|
|
124
|
-
header: 'Sentio upload',
|
|
125
|
-
content: 'sentio upload',
|
|
126
|
-
},
|
|
127
|
-
{
|
|
128
|
-
header: 'Options',
|
|
129
|
-
optionList: optionDefinitions,
|
|
130
|
-
},
|
|
131
|
-
]);
|
|
132
|
-
console.log(usage);
|
|
133
|
-
}
|
|
134
|
-
else {
|
|
135
|
-
if (options.host) {
|
|
136
|
-
processorConfig.host = options.host;
|
|
137
|
-
}
|
|
138
|
-
if (options.nobuild) {
|
|
139
|
-
processorConfig.build = false;
|
|
140
|
-
}
|
|
141
|
-
if (options.debug) {
|
|
142
|
-
processorConfig.debug = true;
|
|
143
|
-
}
|
|
144
|
-
(0, config_1.finalizeHost)(processorConfig);
|
|
145
|
-
(0, config_1.FinalizeProjectName)(processorConfig, options.owner);
|
|
146
|
-
console.log(processorConfig);
|
|
147
|
-
let apiOverride = undefined;
|
|
148
|
-
if (options['api-key']) {
|
|
149
|
-
apiOverride = options['api-key'];
|
|
150
|
-
}
|
|
151
|
-
(0, upload_1.uploadFile)(processorConfig, apiOverride);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
else if (mainOptions.command === 'build') {
|
|
155
|
-
(0, build_1.buildProcessor)(false);
|
|
156
|
-
}
|
|
157
|
-
else if (mainOptions.command === 'gen') {
|
|
158
|
-
(0, build_1.buildProcessor)(true);
|
|
159
|
-
}
|
|
160
|
-
else {
|
|
161
|
-
usage();
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
function usage() {
|
|
165
|
-
const usage = (0, command_line_usage_1.default)([
|
|
166
|
-
{
|
|
167
|
-
header: 'Sentio',
|
|
168
|
-
content: 'Login & Manage your project files to Sentio.',
|
|
169
|
-
},
|
|
170
|
-
{
|
|
171
|
-
header: 'Usage',
|
|
172
|
-
content: [
|
|
173
|
-
'sentio <command> --help\t\tshow detail usage of specific command',
|
|
174
|
-
'sentio login\t\t\t\tlogin to sentio',
|
|
175
|
-
'sentio create\t\t\t\tcreate a template project',
|
|
176
|
-
'sentio upload\t\t\t\tbuild and upload processor to sentio',
|
|
177
|
-
'sentio gen\t\t\t\tgenerate abi',
|
|
178
|
-
'sentio build\t\t\t\tgenerate abi and build',
|
|
179
|
-
'sentio version\t\t\tcurrent cli version',
|
|
180
|
-
],
|
|
181
|
-
},
|
|
182
|
-
]);
|
|
183
|
-
console.log(usage);
|
|
184
|
-
process.exit(1);
|
|
185
|
-
}
|
|
186
|
-
//# 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,0EAA+C;AAC/C,4EAAiD;AACjD,4CAAmB;AACnB,gDAAuB;AAEvB,sDAA0B;AAC1B,qCAAiF;AACjF,qCAAqC;AACrC,kDAAyB;AACzB,mCAAwC;AACxC,sDAAiD;AACjD,wDAAmD;AACnD,oDAA+C;AAE/C,MAAM,eAAe,GAAG,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAA;AAClE,MAAM,WAAW,GAAG,IAAA,2BAAe,EAAC,eAAe,EAAE;IACnD,kBAAkB,EAAE,IAAI;CACzB,CAAC,CAAA;AACF,MAAM,IAAI,GAAG,WAAW,CAAC,QAAQ,IAAI,EAAE,CAAA;AAEvC,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE;IACxB,KAAK,EAAE,CAAA;CACR;AAED,IAAI,WAAW,CAAC,OAAO,KAAK,OAAO,EAAE;IACnC,IAAA,oBAAQ,EAAC,IAAI,CAAC,CAAA;CACf;KAAM,IAAI,WAAW,CAAC,OAAO,KAAK,QAAQ,EAAE;IAC3C,IAAA,sBAAS,EAAC,IAAI,CAAC,CAAA;CAChB;KAAM,IAAI,WAAW,CAAC,OAAO,KAAK,SAAS,EAAE;IA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AO,EAAE,8CAA8C;SACxD;QACD;YACE,MAAM,EAAE,OAAO;YACf,OAAO,EAAE;gBACP,kEAAkE;gBAClE,qCAAqC;gBACrC,gDAAgD;gBAChD,2DAA2D;gBAC3D,gCAAgC;gBAChC,4CAA4C;gBAC5C,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 'js-yaml'\nimport { finalizeHost, FinalizeProjectName, SentioProjectConfig } from './config'\nimport { uploadFile } from './upload'\nimport chalk from 'chalk'\nimport { buildProcessor } from './build'\nimport { runCreate } from './commands/run-create'\nimport { runVersion } from './commands/run-version'\nimport { runLogin } from './commands/run-login'\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 runCreate(argv)\n} else if (mainOptions.command === 'version') {\n runVersion(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: SentioProjectConfig = { host: '', project: '', build: true, debug: false }\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.load(fs.readFileSync('sentio.yaml', 'utf8')) as SentioProjectConfig\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 const optionDefinitions = [\n {\n name: 'help',\n alias: 'h',\n type: Boolean,\n description: 'Display this usage guide.',\n },\n {\n name: 'api-key',\n type: String,\n description: '(Optional) Manually provide API key rather than use saved credential',\n },\n {\n name: 'host',\n description: '(Optional) Override Sentio Host name',\n type: String,\n },\n {\n name: 'owner',\n description: '(Optional) Override Project owner',\n type: String,\n },\n {\n name: 'nobuild',\n description: '(Optional) Skip build & pack file before uploading, default false',\n type: Boolean,\n },\n {\n name: 'debug',\n description: '(Optional) Set driver logging level to debug',\n type: Boolean,\n },\n ]\n const options = commandLineArgs(optionDefinitions, { argv })\n if (options.help) {\n const usage = commandLineUsage([\n {\n header: 'Sentio upload',\n content: 'sentio upload',\n },\n {\n header: 'Options',\n optionList: optionDefinitions,\n },\n ])\n console.log(usage)\n } else {\n if (options.host) {\n processorConfig.host = options.host\n }\n if (options.nobuild) {\n processorConfig.build = false\n }\n if (options.debug) {\n processorConfig.debug = true\n }\n finalizeHost(processorConfig)\n FinalizeProjectName(processorConfig, options.owner)\n console.log(processorConfig)\n\n let apiOverride = undefined\n if (options['api-key']) {\n apiOverride = options['api-key']\n }\n uploadFile(processorConfig, apiOverride)\n }\n } else if (mainOptions.command === 'build') {\n buildProcessor(false)\n } else if (mainOptions.command === 'gen') {\n buildProcessor(true)\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 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 version\\t\\t\\tcurrent cli version',\n ],\n },\n ])\n console.log(usage)\n process.exit(1)\n}\n"]}
|