Skip to content

Commit a909031

Browse files
authored
refactor(firestore-translate-text): move package.json into functions dir (#222)
1 parent 1d7cbbe commit a909031

17 files changed

+37
-2071
lines changed

firestore-translate-text/extension.yaml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ contributors:
3333
- authorName: Chris Bianca
3434
email: chris@csfrequency.com
3535
url: https://github.com/chrisbianca
36+
- authorName: Invertase
37+
email: oss@invertase.io
38+
url: https://github.com/invertase
3639

3740
billingRequired: true
3841

@@ -51,7 +54,6 @@ resources:
5154
Listens for writes of new strings to your specified Cloud Firestore collection, translates the strings,
5255
then writes the translated strings back to the same document.
5356
properties:
54-
sourceDirectory: .
5557
location: ${LOCATION}
5658
eventTrigger:
5759
eventType: providers/cloud.firestore/eventTypes/document.write
@@ -62,9 +64,9 @@ params:
6264
type: select
6365
label: Cloud Functions location
6466
description: >-
65-
Where do you want to deploy the functions created for this extension?
66-
You usually want a location close to your database. For help selecting a
67-
location, refer to the [location selection
67+
Where do you want to deploy the functions created for this extension?
68+
You usually want a location close to your database. For help selecting a
69+
location, refer to the [location selection
6870
guide](https://firebase.google.com/docs/functions/locations).
6971
options:
7072
- label: Iowa (us-central1)

firestore-translate-text/__tests__/config.test.ts renamed to firestore-translate-text/functions/__tests__/config.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import * as functionsTestInit from "firebase-functions-test";
55
import * as yaml from "js-yaml";
66
import mockedEnv from "mocked-env";
77

8-
import { messages } from "../functions/src/logs/messages";
8+
import { messages } from "../src/logs/messages";
99

1010
let restoreEnv;
1111
let extensionYaml;
@@ -26,7 +26,7 @@ functionsTestInit();
2626
describe("extension config", () => {
2727
beforeAll(() => {
2828
extensionYaml = yaml.safeLoad(
29-
readFileSync(pathResolve(__dirname, "../extension.yaml"), "utf8")
29+
readFileSync(pathResolve(__dirname, "../../extension.yaml"), "utf8")
3030
);
3131

3232
extensionParams = extensionYaml.params.reduce((obj, param) => {
@@ -49,7 +49,7 @@ describe("extension config", () => {
4949
});
5050

5151
test("config is logged on initialize", () => {
52-
jest.requireActual("../functions/src");
52+
jest.requireActual("../src");
5353

5454
const functionsConfig = config();
5555

@@ -64,7 +64,7 @@ describe("extension config", () => {
6464
});
6565

6666
test("removes any duplicated languages from user input", () => {
67-
const functionsConfig = require("../functions/src/config").default;
67+
const functionsConfig = require("../src/config").default;
6868
expect(functionsConfig.languages).toEqual(["en", "es", "de", "fr"]);
6969
});
7070

firestore-translate-text/__tests__/functions.test.ts renamed to firestore-translate-text/functions/__tests__/functions.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import mockedEnv from "mocked-env";
22
import * as functionsTestInit from "firebase-functions-test";
33

4-
import { messages } from "../functions/src/logs/messages";
4+
import { messages } from "../src/logs/messages";
55

66
const defaultEnvironment = {
77
PROJECT_ID: "fake-project",
@@ -40,7 +40,7 @@ describe("extension", () => {
4040
});
4141

4242
test("functions are exported", () => {
43-
const exportedFunctions = jest.requireActual("../functions/src");
43+
const exportedFunctions = jest.requireActual("../src");
4444
expect(exportedFunctions.fstranslate).toBeInstanceOf(Function);
4545
});
4646

@@ -74,7 +74,7 @@ describe("extension", () => {
7474
// need to reset modules
7575
jest.resetModules();
7676
// so we can require clean ../function/src that has not been called
77-
require("../functions/src");
77+
require("../src");
7878

7979
expect(mockTranslateClass).toHaveBeenCalledTimes(1);
8080
expect(mockTranslateClass).toHaveBeenCalledWith({

firestore-translate-text/__tests__/jest.setup.ts renamed to firestore-translate-text/functions/__tests__/jest.setup.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
mockTranslateModuleFactory,
1414
} from "./mocks/translate";
1515

16-
global.config = () => require("../functions/src/config").default;
16+
global.config = () => require("../src/config").default;
1717

1818
global.snapshot = snapshot;
1919

firestore-translate-text/__tests__/mocks/translate.ts renamed to firestore-translate-text/functions/__tests__/mocks/translate.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export const testTranslations = {
99

1010
export const mockTranslate = () => {
1111
let functionsTest = functionsTestInit();
12-
return functionsTest.wrap(require("../../functions/src").fstranslate);
12+
return functionsTest.wrap(require("../../src").fstranslate);
1313
};
1414

1515
// await translate.translate('hello', 'de');

0 commit comments

Comments
 (0)