Skip to content

Commit 5d82d08

Browse files
committed
add deploy environment support
1 parent 589875a commit 5d82d08

File tree

7 files changed

+79
-27
lines changed

7 files changed

+79
-27
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# v0.4.9
2+
- chore: add environment flag to deploy command
3+
14
# v0.4.8
25
- fix: small bug in `arkiver deploy` where it was incorrectly uploading the name string as the arkiver
36

cli.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
} from './cli/mod.ts'
1515
import 'https://deno.land/std@0.179.0/dotenv/load.ts'
1616

17-
export const version = 'v0.4.8'
17+
export const version = 'v0.4.9'
1818

1919
const command = new Command()
2020
.name('arkiver')
@@ -50,6 +50,7 @@ command
5050
.command('deploy', 'Deploy arkive')
5151
.option('--public', 'Make arkive public')
5252
.option('--major', 'Deploy as major version')
53+
.option('--env <env:string>', 'Environment to deploy to')
5354
.arguments('<dir:string>')
5455
.action(async (opts, ...args) => {
5556
await checkVersion(version)

cli/deploy/mod.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import { pkg } from './pkg.ts'
44
import { upload } from './upload.ts'
55

66
export const action = async (
7-
options: { public?: true; major?: true },
7+
options: { public?: true; major?: true, env?: string },
88
directory: string,
99
) => {
10-
const dev = Deno.env.get('DEV') !== undefined
10+
const dev = options.env?.toLowerCase() === 'dev'
1111

1212
if (dev) return deployDev(options, directory)
1313

cli/deploy/upload.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export const upload = async (
77
pkgName: string,
88
tempPath: string,
99
manifest: ArkiveManifest,
10-
options: { public?: true; major?: true },
10+
options: { public?: true; major?: true, env?: string },
1111
) => {
1212
const supabase = getSupabaseClient()
1313
const sessionRes = await supabase.auth.getSession()
@@ -39,6 +39,9 @@ export const upload = async (
3939
} else {
4040
formData.append('update', 'minor')
4141
}
42+
if (options.env) {
43+
formData.append('env', options.env)
44+
}
4245

4346
const headers = new Headers()
4447
headers.append(

deno.lock

+45-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/arkiver/types.ts

+22-22
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,15 @@ export type EventHandlerFor<
8282
TEventName extends ExtractAbiEventNames<TAbi>,
8383
> = EventHandler<ExtractAbiEvent<TAbi, TEventName>, TEventName, TAbi>
8484

85-
type OneDeepNonNullable<T> = {
86-
[K in keyof T]: NonNullable<T[K]>
87-
}
85+
type RecursiveNonNullable<T> = T extends {} ? {
86+
[K in keyof T]-?: RecursiveNonNullable<T[K]>
87+
} : NonNullable<T>
8888

89-
export type SafeLog<TAbiEvent extends AbiEvent> = OneDeepNonNullable<
89+
export type SafeLog<TAbiEvent extends AbiEvent> = RecursiveNonNullable<
9090
Log<bigint, bigint, TAbiEvent, [TAbiEvent], string>
9191
>
9292

93-
export type SafeRpcLog = OneDeepNonNullable<RpcLog>
93+
export type SafeRpcLog = RecursiveNonNullable<RpcLog>
9494

9595
export interface EventHandlerContext<
9696
TAbiEvent extends AbiEvent,
@@ -112,7 +112,7 @@ export interface BlockHandlerContext {
112112
logger: log.Logger
113113
}
114114

115-
export type SafeBlock = OneDeepNonNullable<Block>
115+
export type SafeBlock = RecursiveNonNullable<Block>
116116

117117
export type EventHandler<
118118
TAbiEvent extends AbiEvent,
@@ -164,19 +164,19 @@ type ValidNameChars =
164164

165165
export type CheckManifestName<Name extends string, FullName extends string> =
166166
Name extends `${infer First}${infer Rest}`
167-
? First extends ValidNameChars | Capitalize<ValidNameChars>
168-
? CheckManifestName<Rest, FullName>
169-
: `Invalid character in manifest name: ${First}`
170-
: FullName
167+
? First extends ValidNameChars | Capitalize<ValidNameChars>
168+
? CheckManifestName<Rest, FullName>
169+
: `Invalid character in manifest name: ${First}`
170+
: FullName
171171

172172
export type HexString<Str extends string, Length extends number> = Str extends
173173
`0x${infer Rest}`
174174
? InnerHexStr<Rest, Length> extends number
175-
? InnerHexStr<Rest, Length> extends Length ? Str
176-
: `Invalid hex string length. Expected ${Length}, got ${InnerHexStr<
177-
Rest,
178-
Length
179-
>}`
175+
? InnerHexStr<Rest, Length> extends Length ? Str
176+
: `Invalid hex string length. Expected ${Length}, got ${InnerHexStr<
177+
Rest,
178+
Length
179+
>}`
180180
: `Invalid hex character in string: ${InnerHexStr<Rest, Length>}`
181181
: 'Missing 0x prefix'
182182

@@ -186,7 +186,7 @@ type InnerHexStr<
186186
LengthStore extends never[] = [],
187187
> = Str extends `${infer First}${infer Rest}`
188188
? First extends HexChars | Capitalize<HexChars>
189-
? InnerHexStr<Rest, Length, [...LengthStore, never]>
189+
? InnerHexStr<Rest, Length, [...LengthStore, never]>
190190
: First
191191
: LengthStore['length'] extends Length ? Length
192192
: LengthStore['length']
@@ -211,9 +211,9 @@ type HexChars =
211211

212212
export type ValidateSourcesObject<Sources extends Record<string, bigint>> =
213213
keyof Sources extends string
214-
? keyof Sources extends HexString<keyof Sources, 40> | '*'
215-
? keyof Sources extends '*' ? Sources
216-
: keyof Sources extends HexString<keyof Sources, 40> ? Sources
217-
: 'Can\'t mix wildcard and specific addresses'
218-
: HexString<keyof Sources, 40>
219-
: `Source addresses must be strings`
214+
? keyof Sources extends HexString<keyof Sources, 40> | '*'
215+
? keyof Sources extends '*' ? Sources
216+
: keyof Sources extends HexString<keyof Sources, 40> ? Sources
217+
: 'Can\'t mix wildcard and specific addresses'
218+
: HexString<keyof Sources, 40>
219+
: `Source addresses must be strings`

src/deps.ts

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export {
1111
type Log,
1212
type PublicClient,
1313
type RpcLog,
14+
type DecodeEventLogReturnType
1415
} from 'npm:viem'
1516
export {
1617
type Abi,

0 commit comments

Comments
 (0)