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
6 changes: 3 additions & 3 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ Turns a Token Host Schema (THS) document into deterministic Solidity artifacts a

## Quickstart (New Pipeline)

Prereqs: Node >= 20, pnpm (repo uses `packageManager`), Foundry required for local anvil (`th dev` default) and for `th verify`.
Prereqs: Node >= 20, pnpm (repo uses `packageManager`), Foundry required for local anvil (`th up` default) and for `th verify`.

```bash
pnpm install
pnpm th doctor

# One command: validate + build + start anvil + deploy + serve UI
pnpm th dev apps/example/job-board.schema.json
# One command: validate + build + start anvil + deploy + serve UI + local faucet
pnpm th up apps/example/job-board.schema.json

# Open http://127.0.0.1:3000/
# MetaMask: approve switching/adding the Anvil network (chainId 31337).
Expand Down
12 changes: 7 additions & 5 deletions packages/cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1074,7 +1074,7 @@ function buildFromSchema(
console.log('');
console.log('Next steps:');
if (opts.schemaPathForHints) {
console.log(` th dev ${opts.schemaPathForHints} # build+deploy+preview (local)`);
console.log(` th up ${opts.schemaPathForHints} # build+deploy+preview (local)`);
}
console.log(` th deploy ${resolvedOutDir} --chain anvil # start anvil first`);
console.log(` th deploy ${resolvedOutDir} --chain sepolia # requires RPC + funded key`);
Expand Down Expand Up @@ -1302,7 +1302,7 @@ program
'',
'```bash',
`pnpm th doctor`,
`pnpm th dev ${schemaPath}`,
`pnpm th up ${schemaPath}`,
'```',
''
].join('\n')
Expand Down Expand Up @@ -1473,9 +1473,11 @@ function anyPaidCreates(schema: ThsSchema): boolean {
}

program
.command('dev')
.command('up')
.alias('run')
.alias('dev')
.argument('[schema]', 'Path to THS schema JSON file (defaults to an example schema when available)')
.description('All-in-one local dev: validate + build + (start anvil) + deploy + preview')
.description('All-in-one local flow: validate + build + (start anvil) + deploy + preview + faucet')
.option('--out <dir>', 'Build output directory (defaults to artifacts/<appSlug>)')
.option('--chain <name>', 'Chain name (anvil|sepolia)', 'anvil')
.option('--rpc <url>', 'RPC URL override')
Expand Down Expand Up @@ -1562,7 +1564,7 @@ program
} else {
if (!interactive) {
console.error('No schema provided and none found under apps/.');
console.error('Run: th dev <path/to/schema.schema.json>');
console.error('Run: th up <path/to/schema.schema.json>');
process.exitCode = 1;
return;
}
Expand Down
27 changes: 23 additions & 4 deletions test/testCliDev.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,37 @@ function minimalSchema(overrides = {}) {
};
}

describe('th dev', function () {
it('supports --dry-run (no side effects)', function () {
describe('th up/run/dev', function () {
it('supports --dry-run (no side effects) via th up', function () {
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'th-dev-'));
const schemaPath = path.join(dir, 'schema.json');
writeJson(schemaPath, minimalSchema());

const res = runTh(['dev', schemaPath, '--dry-run'], process.cwd());
const res = runTh(['up', schemaPath, '--dry-run'], process.cwd());
expect(res.status, res.stderr || res.stdout).to.equal(0);
expect(res.stdout).to.include('Plan:');
expect(res.stdout).to.include('- build:');
expect(res.stdout).to.include('- deploy:');
expect(res.stdout).to.include('- preview:');
});
});

it('supports --dry-run via th run alias', function () {
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'th-run-'));
const schemaPath = path.join(dir, 'schema.json');
writeJson(schemaPath, minimalSchema());

const res = runTh(['run', schemaPath, '--dry-run'], process.cwd());
expect(res.status, res.stderr || res.stdout).to.equal(0);
expect(res.stdout).to.include('Plan:');
});

it('keeps th dev alias working', function () {
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'th-dev-'));
const schemaPath = path.join(dir, 'schema.json');
writeJson(schemaPath, minimalSchema());

const res = runTh(['dev', schemaPath, '--dry-run'], process.cwd());
expect(res.status, res.stderr || res.stdout).to.equal(0);
expect(res.stdout).to.include('Plan:');
});
});
Loading