Skip to content

Commit a409e18

Browse files
committed
deploy command
1 parent 6621e9f commit a409e18

File tree

2 files changed

+26
-7
lines changed

2 files changed

+26
-7
lines changed

packages/thirdweb/src/cli/bin.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
generate,
55
isValidChainIdAndContractAddress,
66
} from "./commands/generate/generate.js";
7-
import { publishStylus } from "./commands/publish-stylus/publish-stylus.js";
7+
import { deployStylus, publishStylus } from "./commands/stylus/builder.js";
88
// skip the first two args?
99
const [, , command = "", ...rest] = process.argv;
1010

@@ -33,6 +33,11 @@ async function main() {
3333
break;
3434
}
3535

36+
case "deploy-stylus": {
37+
await deployStylus(secretKey);
38+
break;
39+
}
40+
3641
case "login": {
3742
// Not implemented yet
3843
console.info(

packages/thirdweb/src/cli/commands/publish-stylus/publish-stylus.ts renamed to packages/thirdweb/src/cli/commands/stylus/builder.ts

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,31 @@ import { spawnSync } from "node:child_process";
22
import { existsSync, readFileSync } from "node:fs";
33
import { join } from "node:path";
44
import open from "open";
5-
import ora from "ora";
5+
import ora, { type Ora } from "ora";
66
import { createThirdwebClient } from "../../../client/client.js";
77
import { upload } from "../../../storage/upload.js";
88

99
const THIRDWEB_URL = "https://thirdweb.com";
1010

1111
export async function publishStylus(secretKey?: string) {
1212
const spinner = ora("Checking if this is a Stylus project...").start();
13+
const uri = await buildStylus(spinner, secretKey);
1314

15+
const url = getUrl(uri, "publish").toString();
16+
spinner.succeed(`Upload complete, navigate to ${url}`);
17+
await open(url);
18+
}
19+
20+
export async function deployStylus(secretKey?: string) {
21+
const spinner = ora("Checking if this is a Stylus project...").start();
22+
const uri = await buildStylus(spinner, secretKey);
23+
24+
const url = getUrl(uri, "deploy").toString();
25+
spinner.succeed(`Upload complete, navigate to ${url}`);
26+
await open(url);
27+
}
28+
29+
async function buildStylus(spinner: Ora, secretKey?: string) {
1430
if (!secretKey) {
1531
spinner.fail("Error: Secret key is required.");
1632
process.exit(1);
@@ -122,7 +138,7 @@ export async function publishStylus(secretKey?: string) {
122138
});
123139
console.log(bytecodeUri);
124140

125-
const publishUri = await upload({
141+
const uri = await upload({
126142
client,
127143
files: [
128144
{
@@ -143,11 +159,9 @@ export async function publishStylus(secretKey?: string) {
143159
},
144160
],
145161
});
162+
spinner.succeed("Upload complete");
146163

147-
const url = getUrl(publishUri, "publish").toString();
148-
spinner.succeed(`Upload complete: ${url}`);
149-
150-
await open(url);
164+
return uri;
151165
} catch (error) {
152166
spinner.fail(`Error: ${error}`);
153167
process.exit(1);

0 commit comments

Comments
 (0)