Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions bin/stasis.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ function usage(prefix = '') {
console.error(`${prefix}\nUsage:
stasis run --lock=(add|replace|frozen|ignore) [--bundle=(add|replace|load|ignore)] [--bundle-file=path/to/bundle.br] [--full] [--mock] path/to/file.js ...
stasis bundle [--mapping=path/to/remappings(.txt|.toml)] [--output=path/to/out.stasis.code.br] path/to/file.sol ...
stasis bundle [--scope=(node_modules|full)] [--lockfile=path/to/stasis.lock.json] [--output=path/to/out.stasis.code.br] path/to/file.js ...
stasis prune [path/to/project]
stasis audit path/to/file ...
`.trim())
Expand Down Expand Up @@ -126,28 +127,40 @@ if (command === '-v' || command === '--version') {
process.exitCode = code
} else if (command === 'bundle') {
const flags = []
const valueFlags = new Set(['--mapping', '--output', '-o'])
const valueFlags = new Set(['--mapping', '--output', '--scope', '--lockfile', '-o'])
while (argv.length > 0 && (argv[0].startsWith('-') || valueFlags.has(flags.at(-1)))) {
flags.push(argv.shift())
}
const options = {
mapping: { type: 'string' },
output: { type: 'string', short: 'o' },
scope: { type: 'string' },
lockfile: { type: 'string' },
}
let values
try {
({ values } = parseArgs({ args: flags, options }))
} catch (cause) {
usage(`Error: ${cause.message}`)
}
if (argv.length === 0) usage('Nothing to bundle: no .sol file given')
if (!argv.every((f) => f.endsWith('.sol'))) usage('Error: bundle only accepts .sol files')
if (argv.length === 0) usage('Nothing to bundle: no entry file given')
const allSol = argv.every((f) => f.endsWith('.sol'))
const allJs = argv.every((f) => /\.(?:js|cjs|mjs)$/u.test(f))
if (!allSol && !allJs) usage('Error: bundle entries must all be .sol or all be .js/.cjs/.mjs')
if (values.mapping && !allSol) usage('Error: --mapping is only valid for .sol bundles')
if (values.scope && !allJs) usage('Error: --scope is only valid for JS bundles')
if (values.scope && !['node_modules', 'full'].includes(values.scope)) {
usage('Error: --scope must be node_modules or full')
}
if (values.lockfile && !allJs) usage('Error: --lockfile is only valid for JS bundles')
const { bundleCommand } = await import('../src/cmd/bundle.js')
await bundleCommand({
cwd: process.cwd(),
entries: argv,
mappingFile: values.mapping,
output: values.output,
scope: values.scope,
lockfile: values.lockfile,
})
} else if (command === 'prune') {
if (argv.length > 1) usage('Error: prune takes at most one path argument')
Expand Down
10 changes: 10 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"src/lockfile.js",
"src/mock.js",
"src/prune.js",
"src/scan.js",
"src/state.js",
"src/state.util.js",
"src/util.js",
Expand All @@ -54,9 +55,18 @@
"url": "https://github.com/ExodusOSS/stasis/issues"
},
"homepage": "https://github.com/ExodusOSS/stasis#readme",
"peerDependencies": {
"oxc-parser": "*"
},
"peerDependenciesMeta": {
"oxc-parser": {
"optional": true
}
},
"devDependencies": {
"@exodus/bytes": "^1.15.0",
"esbuild": "^0.27.3",
"oxc-parser": "^0.94.0",
"oxlint": "^1.52.0",
"string-replace-loader": "^2.3.0",
"webpack": "^4.47.0"
Expand Down
232 changes: 232 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading