@sentio/cli 2.0.0-rc.8 → 2.0.0
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/cli.js +4 -4
- package/lib/cli.js.map +1 -1
- package/lib/commands/build.d.ts +14 -0
- package/lib/commands/build.js +137 -0
- package/lib/commands/build.js.map +1 -0
- package/lib/commands/run-create.js +0 -11
- package/lib/commands/run-create.js.map +1 -1
- package/lib/commands/run-test.js +3 -2
- package/lib/commands/run-test.js.map +1 -1
- package/lib/commands/run-upload.js +69 -55
- package/lib/commands/run-upload.js.map +1 -1
- package/package.json +4 -4
- package/src/cli.ts +4 -4
- package/src/commands/build.ts +152 -0
- package/src/commands/run-create.ts +0 -12
- package/src/commands/run-test.ts +3 -2
- package/src/commands/run-upload.ts +74 -56
- package/templates/aptos/package.json +1 -2
- package/templates/aptos/tsconfig.json +1 -1
- package/templates/{evm/abis/evm → eth/abis/eth}/x2y2.json +0 -0
- package/templates/{evm → eth}/jest.config.ts +0 -0
- package/templates/{evm → eth}/package.json +1 -1
- package/templates/{evm → eth}/sentio.yaml +0 -0
- package/templates/{evm → eth}/src/processor.ts +3 -4
- package/templates/{evm → eth}/tsconfig.json +1 -1
- package/templates/raw/tsconfig.json +1 -1
- package/templates/solana/package.json +1 -2
- package/templates/solana/src/processor.ts +3 -3
- package/templates/solana/tsconfig.json +1 -1
- package/lib/build.d.ts +0 -2
- package/lib/build.js +0 -100
- package/lib/build.js.map +0 -1
- package/src/build.ts +0 -125
package/src/build.ts
DELETED
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk'
|
|
2
|
-
import path from 'path'
|
|
3
|
-
import fs from 'fs'
|
|
4
|
-
import { exec } from 'child_process'
|
|
5
|
-
import * as process from 'process'
|
|
6
|
-
import { getPackageRoot } from './utils.js'
|
|
7
|
-
|
|
8
|
-
export async function buildProcessor(onlyGen: boolean) {
|
|
9
|
-
if (!onlyGen) {
|
|
10
|
-
await installDeps()
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
// targets.forEach(async (target) => await buildProcessorForTarget(onlyGen, target))
|
|
14
|
-
// for (const target) {
|
|
15
|
-
await buildProcessorForTarget(onlyGen)
|
|
16
|
-
// }
|
|
17
|
-
|
|
18
|
-
if (!onlyGen) {
|
|
19
|
-
let WEBPACK_CONFIG: string
|
|
20
|
-
try {
|
|
21
|
-
WEBPACK_CONFIG = path.resolve(getPackageRoot('@sentio/sdk'), 'lib/tsup.config.ts')
|
|
22
|
-
} catch (e) {
|
|
23
|
-
console.error(chalk.red("Wrong CLI version for sdk, can't find tsup.config.ts"))
|
|
24
|
-
process.exit(1)
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// await execStep('yarn tsc -p .', 'Compile')
|
|
28
|
-
await execStep('yarn tsup --config=' + WEBPACK_CONFIG, 'Packaging')
|
|
29
|
-
|
|
30
|
-
const dir = fs.readdirSync(path.join(process.cwd(), 'dist'))
|
|
31
|
-
const generated = dir.filter((d) => d.endsWith('.js')).length
|
|
32
|
-
if (generated < 0) {
|
|
33
|
-
console.error(chalk.red('No filed generated, please check if your processor.ts file'))
|
|
34
|
-
process.exit(1)
|
|
35
|
-
}
|
|
36
|
-
if (generated > 1) {
|
|
37
|
-
console.error(
|
|
38
|
-
chalk.red('Packing failed: '),
|
|
39
|
-
`Multiple entry point is not allowed. If your processor.ts have multiple file imported, please change:
|
|
40
|
-
import('mine.js')
|
|
41
|
-
to
|
|
42
|
-
import 'mine.js'
|
|
43
|
-
`
|
|
44
|
-
)
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
async function buildProcessorForTarget(onlyGen: boolean) {
|
|
50
|
-
await codeGenEthersProcessor(path.join('abis', 'evm'))
|
|
51
|
-
|
|
52
|
-
try {
|
|
53
|
-
// @ts-ignore dynamic import
|
|
54
|
-
const codegen = await import('@sentio/sdk-solana/codegen')
|
|
55
|
-
codegen.codeGenSolanaProcessor(path.join('abis', 'solana'))
|
|
56
|
-
} catch (e) {}
|
|
57
|
-
|
|
58
|
-
try {
|
|
59
|
-
// @ts-ignore dynamic import
|
|
60
|
-
const codegen = await import('@sentio/sdk-aptos/codegen')
|
|
61
|
-
codegen.codeGenAptosProcessor(path.join('abis', 'aptos'))
|
|
62
|
-
} catch (e) {}
|
|
63
|
-
|
|
64
|
-
if (onlyGen) {
|
|
65
|
-
return
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
async function installDeps() {
|
|
70
|
-
await execStep('yarn install --ignore-scripts', 'Yarn Install')
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export async function codeGenEthersProcessor(
|
|
74
|
-
abisDir: string,
|
|
75
|
-
ETHERS_TARGET = path.resolve(getPackageRoot('@sentio/sdk'), 'lib/target-ethers-sentio/index.cjs'),
|
|
76
|
-
outDir = 'src/types/internal'
|
|
77
|
-
) {
|
|
78
|
-
if (!fs.existsSync(abisDir)) {
|
|
79
|
-
return
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
let haveJson = false
|
|
83
|
-
const files = fs.readdirSync(abisDir)
|
|
84
|
-
for (const file of files) {
|
|
85
|
-
if (file.toLowerCase().endsWith('.json')) {
|
|
86
|
-
haveJson = true
|
|
87
|
-
break
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
if (!haveJson) {
|
|
91
|
-
return
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
console.log(chalk.green('Generated Types for EVM'))
|
|
95
|
-
|
|
96
|
-
// TODO this will fail during postinstall, need to locate real typechain path
|
|
97
|
-
await execStep(
|
|
98
|
-
'yarn typechain --target ' + ETHERS_TARGET + ` --out-dir ${outDir} ${path.join(abisDir, '*.json')}`,
|
|
99
|
-
'Type definitions gen'
|
|
100
|
-
)
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
async function execStep(cmd: string, stepName: string) {
|
|
104
|
-
const child = exec(cmd)
|
|
105
|
-
console.log(chalk.blue(stepName + ' begin'))
|
|
106
|
-
|
|
107
|
-
if (!child.stdout || !child.stderr) {
|
|
108
|
-
console.error(chalk.red(stepName + ' failed'))
|
|
109
|
-
process.exit(1)
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
child.stdout.pipe(process.stdout)
|
|
113
|
-
child.stderr.pipe(process.stderr)
|
|
114
|
-
|
|
115
|
-
await new Promise((resolve) => {
|
|
116
|
-
child.on('close', resolve)
|
|
117
|
-
})
|
|
118
|
-
|
|
119
|
-
if (child.exitCode) {
|
|
120
|
-
console.error(chalk.red(stepName + ' failed'))
|
|
121
|
-
process.exit(child.exitCode)
|
|
122
|
-
}
|
|
123
|
-
console.log(chalk.blue(stepName + ' success'))
|
|
124
|
-
console.log()
|
|
125
|
-
}
|