Skip to content

Commit f1a86db

Browse files
committed
refactor: fix eslint errors from rebase
1 parent f0c89f6 commit f1a86db

File tree

5 files changed

+16
-19
lines changed

5 files changed

+16
-19
lines changed

src/utils/deploy/deploy-site.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ import hashFiles from './hash-files.js'
2020
import hashFns from './hash-fns.js'
2121
import uploadFiles from './upload-files.js'
2222
import { getUploadList, waitForDeploy, waitForDiff } from './util.js'
23+
import type { DeployEvent } from './status-cb.js'
24+
25+
export type { DeployEvent }
2326

2427
const buildStatsString = (possibleParts: (string | false | undefined)[]) => {
2528
const parts = possibleParts.filter(Boolean)
@@ -28,13 +31,6 @@ const buildStatsString = (possibleParts: (string | false | undefined)[]) => {
2831
return parts.length > 1 ? `${message} and ${parts[parts.length - 1]}` : message
2932
}
3033

31-
// TODO(serhalp): This is alternatingly called "event", "status", and "progress". Standardize.
32-
export interface DeployEvent {
33-
type: string
34-
msg: string
35-
phase: 'start' | 'progress' | 'error' | 'stop'
36-
}
37-
3834
export const deploySite = async (
3935
command: BaseCommand,
4036
api: $TSFixMe,
@@ -115,7 +111,6 @@ export const deploySite = async (
115111
concurrentHash,
116112
hashAlgorithm,
117113
statusCb,
118-
assetType,
119114
manifestPath,
120115
skipFunctionsCache,
121116
rootDir: siteRoot,

src/utils/deploy/hash-files.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const hashFiles = async ({
3030
const files = {}
3131
// hash: [fileObj, fileObj, fileObj]
3232
const filesShaMap = {}
33-
const manifestCollector = manifestCollectorCtor(files, filesShaMap, { statusCb, assetType })
33+
const manifestCollector = manifestCollectorCtor(files, filesShaMap, { statusCb })
3434

3535
await pipeline([fileStream, fileFilter, hasher, fileNormalizer, manifestCollector])
3636

src/utils/deploy/hash-fns.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,6 @@ const hashFns = async (
108108
command: BaseCommand,
109109
directories: string[],
110110
config: {
111-
/** @default 'function' */
112-
assetType?: string
113111
concurrentHash?: number
114112
functionsConfig: $TSFixMe
115113
/** @default 'sha256' */
@@ -122,7 +120,6 @@ const hashFns = async (
122120
},
123121
): Promise<$TSFixMe> => {
124122
const {
125-
assetType = 'function',
126123
concurrentHash,
127124
functionsConfig,
128125
hashAlgorithm = 'sha256',
@@ -219,7 +216,7 @@ const hashFns = async (
219216
const functions = {}
220217
// hash: [fileObj, fileObj, fileObj]
221218
const fnShaMap = {}
222-
const manifestCollector = manifestCollectorCtor(functions, fnShaMap, { statusCb, assetType })
219+
const manifestCollector = manifestCollectorCtor(functions, fnShaMap, { statusCb })
223220

224221
await pipeline([functionStream, hasher, manifestCollector])
225222
return { functionSchedules, functions, functionsWithNativeModules, fnShaMap, fnConfig }

src/utils/deploy/hasher-segments.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { pipeline } from 'node:stream/promises'
66
import transform from 'parallel-transform'
77

88
import { normalizePath } from './util.js'
9+
import { StatusCallback } from './status-cb.js'
910

1011
const hashFile = async (filePath: string, algorithm: string) => {
1112
const hasher = createHash(algorithm)
@@ -58,13 +59,11 @@ export const fileNormalizerCtor = ({
5859
export const manifestCollectorCtor = (
5960
filesObj: Record<string, unknown>,
6061
shaMap: Record<string, unknown[]>,
61-
{ assetType, statusCb }: { assetType: string; statusCb: Function },
62+
{ statusCb }: { statusCb: StatusCallback },
6263
) => {
63-
if (!statusCb || !assetType) throw new Error('Missing required options')
64-
6564
return new Writable({
6665
objectMode: true,
67-
write(fileObj, encoding, callback) {
66+
write(fileObj, _encoding, callback) {
6867
filesObj[fileObj.normalizedPath] = fileObj.hash
6968

7069
// Maintain hash to fileObj mapping
@@ -84,7 +83,6 @@ export const manifestCollectorCtor = (
8483
},
8584
})
8685
}
87-
/* eslint-enable promise/prefer-await-to-callbacks */
8886

8987
export const fileFilterCtor = () =>
9088
new Transform({
@@ -93,7 +91,6 @@ export const fileFilterCtor = () =>
9391
if (fileObj.type === 'file') {
9492
this.push(fileObj)
9593
}
96-
// eslint-disable-next-line promise/prefer-await-to-callbacks
9794
callback()
9895
},
9996
})

src/utils/deploy/status-cb.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// TODO(serhalp): This is alternatingly called "event", "status", and "progress". Standardize.
2+
export interface DeployEvent {
3+
type: string
4+
msg: string
5+
phase: 'start' | 'progress' | 'error' | 'stop'
6+
}
7+
8+
export type StatusCallback = (status: DeployEvent) => void

0 commit comments

Comments
 (0)