Skip to content

Commit

Permalink
Rename gcp-migrations to gcp-firestore-migrations and convert to ESM …
Browse files Browse the repository at this point in the history
…and vitest

 - package.json update
 - replace jest config with vitest config
 - search/replace to add js extension
 - manually fix directory imports with index.js
 - jest.xxx to vi.xxx
 - setup-tests to use globals, etc
 - skip updating firestore lib for now because of breaking changes
 - jump a couple of versions in gcp-firestore alpha because of mess up with lib updates
  • Loading branch information
mbyrne00 committed Dec 8, 2023
1 parent 3a9ac07 commit 15a628b
Show file tree
Hide file tree
Showing 20 changed files with 65 additions and 69 deletions.
44 changes: 22 additions & 22 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# MONDOKIT GCP MIGRATIONS
# MONDOKIT GCP FIRESTORE MIGRATIONS

Setup and Run migrations, with state stored in firestore and a mutex lock to ensure only one is run at a time

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"name": "@mondokit/gcp-migrations",
"name": "@mondokit/gcp-firestore-migrations",
"version": "1.0.0-alpha.0",
"description": "",
"type": "module",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"files": [
Expand All @@ -13,8 +14,8 @@
"firestore:start": "npx --yes firebase-tools emulators:start --project firestore-tests",
"format": "prettier --write \"./src/**/*.ts\"",
"prepublishOnly": "npm run build",
"test": "jest --runInBand",
"test:ci": "firebase emulators:exec --only firestore --project firestore-tests \"jest --runInBand\""
"test": "vitest run",
"test:ci": "npx --yes firebase-tools emulators:exec --only firestore --project firestore-tests \"vitest run\""
},
"publishConfig": {
"access": "public"
Expand All @@ -23,16 +24,16 @@
"license": "MIT",
"homepage": "https://github.com/mondo-mob/mondokit",
"dependencies": {
"lodash": "^4.17.21"
"lodash-es": "^4.17.21"
},
"peerDependencies": {
"@mondomob/gae-js-core": "^7.0.0",
"@mondomob/gae-js-firestore": "^17.0.0"
"@mondokit/gcp-core": "^1.0.0-alpha.1",
"@mondokit/gcp-firestore": "^1.0.0-alpha.2"
},
"devDependencies": {
"@google-cloud/firestore": "6.6.1",
"@mondomob/gae-js-core": "7.0.3",
"@mondomob/gae-js-firestore": "17.0.0"
"@google-cloud/firestore": "^6.6.1",
"@mondokit/gcp-core": "1.0.0-alpha.1",
"@mondokit/gcp-firestore": "1.0.0-alpha.2"
},
"gitHead": "087032afa8903aa576041cdfe4913fe8f115e919"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import "vitest/globals.d.ts";
import "jest-extended";
import nock from "nock";
import matchers from "jest-extended";

expect.extend(matchers);

nock.disableNetConnect();
nock.enableNetConnect("127.0.0.1");
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
import { CollectionReference, Firestore, Settings } from "@google-cloud/firestore";
import { configurationProvider, runWithRequestStorage, zodValidator } from "@mondomob/gae-js-core";
import {
FirestoreLoader,
firestoreLoaderRequestStorage,
firestoreProvider,
GaeJsFirestoreConfiguration,
gaeJsFirestoreConfigurationSchema,
} from "@mondomob/gae-js-firestore";
import ProvidesCallback = jest.ProvidesCallback;
import { configurationProvider, runWithRequestStorage, zodValidator } from "@mondokit/gcp-core";
import { FirestoreLoader, firestoreLoaderRequestStorage, firestoreProvider, GaeJsFirestoreConfiguration, gaeJsFirestoreConfigurationSchema } from "@mondokit/gcp-firestore";


export const initTestConfig = async (
config?: Partial<GaeJsFirestoreConfiguration>
Expand Down Expand Up @@ -62,7 +56,7 @@ export const useFirestoreTest = (collectionsToClear: string[] = []) => {
};

// Helper for standalone tests that require transaction support
export const transactional = (testFn: () => Promise<unknown>): ProvidesCallback => {
export const transactional = (testFn: () => Promise<unknown>) => {
return () =>
runWithRequestStorage(async () => {
// We need firestore loader in request storage if we want to use gae-js transactions
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Logger } from "@mondomob/gae-js-core";
import { MigrationOptions } from "./migration";
import { Logger } from "@mondokit/gcp-core";
import { MigrationOptions } from "./migration.js";

export interface MigrateParams {
/**
Expand Down
2 changes: 2 additions & 0 deletions packages/gcp-firestore-migrations/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from "./auto-migration.js";
export * from "./migration.js";
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TimestampedEntity, TimestampedRepository } from "@mondomob/gae-js-firestore";
import { TimestampedEntity, TimestampedRepository } from "@mondokit/gcp-firestore";

// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface MigrationResult extends TimestampedEntity {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import {
newTimestampedEntity,
TimestampedEntity,
TimestampedRepository,
} from "@mondomob/gae-js-firestore";
import { transactional, useFirestoreTest } from "./__test/test-utils";
import { AutoMigration } from "./auto-migration";
import { runMigrations } from "./migration";
import { migrationResultsRepository } from "./migration-results.repository";
import { mutexServiceProvider } from "./mutex";
} from "@mondokit/gcp-firestore";
import { transactional, useFirestoreTest } from "./__test/test-utils.js";
import { AutoMigration } from "./auto-migration.js";
import { runMigrations } from "./migration.js";
import { migrationResultsRepository } from "./migration-results.repository.js";
import { mutexServiceProvider } from "./mutex.js";

const dummyEntityCollectionName = "migrations-dummy-entities";
const ORIG_CREATED_AT = new Date("1999-01-01T00:00:00");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { Bootstrapper, createLogger, runWithRequestStorage, setRequestStorageValue } from "@mondomob/gae-js-core";
import { Bootstrapper, createLogger, runWithRequestStorage, setRequestStorageValue } from "@mondokit/gcp-core";
import {
DISABLE_TIMESTAMP_UPDATE,
FirestoreLoader,
firestoreLoaderRequestStorage,
firestoreProvider,
newTimestampedEntity,
} from "@mondomob/gae-js-firestore";
import { merge } from "lodash";
import { AutoMigration } from "./auto-migration";
import { migrationResultsRepository } from "./migration-results.repository";
import { mutexServiceProvider } from "./mutex";
} from "@mondokit/gcp-firestore";
import { merge } from "lodash-es";
import { AutoMigration } from "./auto-migration.js";
import { migrationResultsRepository } from "./migration-results.repository.js";
import { mutexServiceProvider } from "./mutex.js";

const logger = createLogger("migrations");
const MUTEX_ID = "migrations";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { LazyProvider } from "@mondomob/gae-js-core";
import { MutexService } from "@mondomob/gae-js-firestore";
import { LazyProvider } from "@mondokit/gcp-core";
import { MutexService } from "@mondokit/gcp-firestore";

export const mutexServiceProvider = new LazyProvider(
() =>
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 4 additions & 0 deletions packages/gcp-firestore-migrations/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { defineConfig } from "vitest/config";
import { vitestConfig } from "../../vitest.config.base";

export default defineConfig(vitestConfig());
2 changes: 1 addition & 1 deletion packages/gcp-firestore/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mondokit/gcp-firestore",
"version": "1.0.0-alpha.0",
"version": "1.0.0-alpha.2",
"description": "",
"main": "dist/index.js",
"type": "module",
Expand Down
7 changes: 0 additions & 7 deletions packages/gcp-migrations/jest.config.js

This file was deleted.

2 changes: 0 additions & 2 deletions packages/gcp-migrations/src/index.ts

This file was deleted.

0 comments on commit 15a628b

Please sign in to comment.