Skip to content

Commit b51a98a

Browse files
committed
chore: format
1 parent 6e59d97 commit b51a98a

36 files changed

+129
-126
lines changed

src/actions/exportFirestoreData/Exporter.ts

+13-13
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export class Exporter {
4949
constructor(
5050
private connection: FirestoreConnectionOptions | Firestore,
5151
private writer: IDataSourceWriter,
52-
private logger: Logger
52+
private logger: Logger,
5353
) {}
5454

5555
async run(options: ExportOptions) {
@@ -64,7 +64,7 @@ export class Exporter {
6464
const overwritten = await this.writer.open(overwrite);
6565
if (overwritten)
6666
this.logger.debug(
67-
`Overwriting existing data at ${dir(this.writer.path)}`
67+
`Overwriting existing data at ${dir(this.writer.path)}`,
6868
);
6969

7070
// Get starting paths to explore
@@ -143,7 +143,7 @@ export class Exporter {
143143
`${count(this.exploring)} exploring`,
144144
`${count(this.exploreQueue)} to explore`,
145145
`${count(this.reads)} reads`,
146-
].join(", ")
146+
].join(", "),
147147
);
148148
}
149149

@@ -171,7 +171,7 @@ export class Exporter {
171171

172172
const [docPaths, colPaths] = split(paths, isDocumentPath);
173173
const docPathsFiltered = docPaths.filter((path) =>
174-
typeof depth === "number" ? documentPathDepth(path) < depth : true
174+
typeof depth === "number" ? documentPathDepth(path) < depth : true,
175175
);
176176
this.exploring.decrement(docPaths.length - docPathsFiltered.length);
177177

@@ -183,11 +183,11 @@ export class Exporter {
183183

184184
private async exploreForDocuments(
185185
paths: string[],
186-
limit?: number | undefined
186+
limit?: number | undefined,
187187
) {
188188
if (paths.length > 0)
189189
this.logger.debug(
190-
`Exploring for documents in ${plural(paths, "collection")}`
190+
`Exploring for documents in ${plural(paths, "collection")}`,
191191
);
192192

193193
for (const path of paths) {
@@ -230,7 +230,7 @@ export class Exporter {
230230
private async exploreForSubcollections(paths: string[]) {
231231
if (paths.length > 0)
232232
this.logger.debug(
233-
`Exploring for subcollections in ${plural(paths, "document")}`
233+
`Exploring for subcollections in ${plural(paths, "document")}`,
234234
);
235235

236236
if (this.limitReached) {
@@ -243,8 +243,8 @@ export class Exporter {
243243
// The number of paths shouldn't exceed `exploreChunkSize` anyway
244244
const subcollectionsList = await Promise.all(
245245
paths.map((path) =>
246-
(path ? this.firestore.doc(path) : this.firestore).listCollections()
247-
)
246+
(path ? this.firestore.doc(path) : this.firestore).listCollections(),
247+
),
248248
);
249249

250250
const subcollections = subcollectionsList.flat();
@@ -294,7 +294,7 @@ export class Exporter {
294294
if (readyToExport.length >= remaining) this.limitReached = true;
295295
readyToExport = readyToExport.splice(0, remaining);
296296
this.logger.verbose(
297-
`Exports remaining: ${count(remaining)} / ${count(limit)}`
297+
`Exports remaining: ${count(remaining)} / ${count(limit)}`,
298298
);
299299
}
300300

@@ -307,7 +307,7 @@ export class Exporter {
307307

308308
const [paths, snapshots] = splitStrict(
309309
readyToExport,
310-
(ex): ex is string => typeof ex === "string"
310+
(ex): ex is string => typeof ex === "string",
311311
);
312312

313313
const refs = paths.map((path) => this.firestore.doc(path));
@@ -319,7 +319,7 @@ export class Exporter {
319319
.map((snapshot) => {
320320
const document = FirestoreDocument.serialize(
321321
snapshot.ref.path,
322-
snapshot.data()
322+
snapshot.data(),
323323
);
324324
if (document) return JSON.stringify(document);
325325
return null;
@@ -331,7 +331,7 @@ export class Exporter {
331331
this.exporting.decrement(readyToExport.length);
332332

333333
this.logger.debug(
334-
`Successfully exported ${plural(serializedDocuments, "document")}`
334+
`Successfully exported ${plural(serializedDocuments, "document")}`,
335335
);
336336
}
337337
}

src/actions/exportFirestoreData/exportFirestoreData.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { Exporter } from "./Exporter";
2222
export async function exportFirestoreData(
2323
connection: FirestoreConnectionOptions | Firestore,
2424
writer: IDataSourceWriter,
25-
options: ExportFirestoreDataOptions & LoggingOptions = {}
25+
options: ExportFirestoreDataOptions & LoggingOptions = {},
2626
) {
2727
const level = options.quiet
2828
? "silent"
@@ -54,6 +54,6 @@ export async function exportFirestoreData(
5454
timer.stop(`Exported ${plural(exported, "document")} to ${path}`);
5555
else
5656
timer.stop(
57-
`Exported ${plural(exported, "document")} from ${project} to ${path}`
57+
`Exported ${plural(exported, "document")} from ${project} to ${path}`,
5858
);
5959
}

src/actions/getFirestoreData/getFirestoreData.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { GetFirestoreDataOptions } from "./types";
1313
export function getFirestoreData(
1414
connection: FirestoreConnectionOptions | Firestore,
1515
path: string,
16-
options: { stringify: true | number }
16+
options: { stringify: true | number },
1717
): Promise<string>;
1818

1919
/**
@@ -25,14 +25,14 @@ export function getFirestoreData(
2525
export function getFirestoreData(
2626
connection: FirestoreConnectionOptions | Firestore,
2727
path: string,
28-
options?: { stringify?: false }
28+
options?: { stringify?: false },
2929
): Promise<FirebaseFirestore.DocumentData>;
3030

3131
// Implementation
3232
export async function getFirestoreData(
3333
connection: FirestoreConnectionOptions | Firestore,
3434
path: string,
35-
options: GetFirestoreDataOptions = {}
35+
options: GetFirestoreDataOptions = {},
3636
) {
3737
const firestore = FirestoreFactory.create(connection);
3838
const snapshot = await firestore.doc(path).get();

src/actions/importFirestoreData/Importer.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export class Importer {
4444
constructor(
4545
private connection: FirestoreConnectionOptions | Firestore,
4646
private reader: IDataSourceReader,
47-
private logger: Logger
47+
private logger: Logger,
4848
) {}
4949

5050
async run(options: ImportOptions) {
@@ -130,7 +130,7 @@ export class Importer {
130130
// `${count(this.processing)} processing`,
131131
`${count(this.skipped)} skipped`,
132132
`${count(this.failed)} failed to import`,
133-
].join(", ")
133+
].join(", "),
134134
);
135135
},
136136
});
@@ -148,7 +148,7 @@ export class Importer {
148148
object: unknown,
149149
writer: FirebaseFirestore.BulkWriter,
150150
errors: FirebaseFirestore.BulkWriterError[],
151-
options: ImportOptions
151+
options: ImportOptions,
152152
) {
153153
if (object === null || typeof object !== "object") {
154154
this.processing.decrement(1);
@@ -161,7 +161,7 @@ export class Importer {
161161
try {
162162
document = FirestoreDocument.deserialize(
163163
object as Partial<SerializedFirestoreDocument>,
164-
this.firestore
164+
this.firestore,
165165
);
166166
} catch (error) {
167167
this.processing.decrement(1);

src/actions/importFirestoreData/importFirestoreData.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { Importer } from "./Importer";
2222
export async function importFirestoreData(
2323
connection: FirestoreConnectionOptions | Firestore,
2424
reader: IDataSourceReader,
25-
options: ImportFirestoreDataOptions & LoggingOptions = {}
25+
options: ImportFirestoreDataOptions & LoggingOptions = {},
2626
) {
2727
const level = options.quiet
2828
? "silent"
@@ -55,6 +55,6 @@ export async function importFirestoreData(
5555
timer.stop(`Imported ${plural(imported, "document")} from ${path}`);
5656
else
5757
timer.stop(
58-
`Imported ${plural(imported, "document")} from ${path} to ${project}`
58+
`Imported ${plural(imported, "document")} from ${path} to ${project}`,
5959
);
6060
}

src/actions/listFirestoreData/countFirestoreCollections.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { FirestoreConnectionOptions, FirestoreFactory } from "~/firestore";
1010
*/
1111
export async function countFirestoreCollections(
1212
connection: FirestoreConnectionOptions | Firestore,
13-
path: string | undefined | null
13+
path: string | undefined | null,
1414
) {
1515
const firestore = FirestoreFactory.create(connection);
1616
const ref = path ? firestore.doc(path) : firestore;

src/actions/listFirestoreData/countFirestoreDocuments.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { FirestoreConnectionOptions, FirestoreFactory } from "~/firestore";
99
* @param path Specify the path to the collection to count documents in.
1010
*/ export async function countFirestoreDocuments(
1111
connection: FirestoreConnectionOptions | Firestore,
12-
path: string
12+
path: string,
1313
) {
1414
const firestore = FirestoreFactory.create(connection);
1515
const count = await firestore.collection(path).count().get();

src/actions/listFirestoreData/listFirestoreCollections.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { ListFirestoreDataOptions } from "./types";
1313
export async function listFirestoreCollections(
1414
connection: FirestoreConnectionOptions | Firestore,
1515
path: string | undefined | null,
16-
options: ListFirestoreDataOptions = {}
16+
options: ListFirestoreDataOptions = {},
1717
): Promise<string[]> {
1818
const firestore = FirestoreFactory.create(connection);
1919
const ref = path ? firestore.doc(path) : firestore;

src/actions/listFirestoreData/listFirestoreDocuments.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { ListFirestoreDataOptions } from "./types";
1313
export async function listFirestoreDocuments(
1414
connection: FirestoreConnectionOptions | Firestore,
1515
path: string,
16-
options: ListFirestoreDataOptions = {}
16+
options: ListFirestoreDataOptions = {},
1717
): Promise<string[]> {
1818
const firestore = FirestoreFactory.create(connection);
1919
const snapshot = await firestore.collection(path).listDocuments();

src/cli/createExportCommand.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import {
3434

3535
export function createExportCommand(
3636
cli: Command,
37-
globalOptions: GlobalOptions
37+
globalOptions: GlobalOptions,
3838
) {
3939
cli
4040
.command("export <path>")

src/cli/createImportCommand.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import {
3333

3434
export function createImportCommand(
3535
cli: Command,
36-
globalOptions: GlobalOptions
36+
globalOptions: GlobalOptions,
3737
) {
3838
cli
3939
.command("import <path>")

src/cli/createListCommand.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export function createListCommand(cli: Command, globalOptions: GlobalOptions) {
4141
const output = await listFirestoreDocuments(
4242
config.connection,
4343
path,
44-
options
44+
options,
4545
);
4646
output.forEach((id) => console.log(id));
4747
});
@@ -64,7 +64,7 @@ export function createListCommand(cli: Command, globalOptions: GlobalOptions) {
6464
const output = await listFirestoreCollections(
6565
connection,
6666
path,
67-
action as any
67+
action as any,
6868
);
6969
output.forEach((id) => console.log(id));
7070
process.exit(0);

0 commit comments

Comments
 (0)