Skip to content

Commit

Permalink
Merge pull request #4 from utopia-php/feat-initial-push
Browse files Browse the repository at this point in the history
Feat initial push
  • Loading branch information
christyjacob4 committed Jun 22, 2023
2 parents 3e3a109 + 736a8f8 commit 2acef10
Show file tree
Hide file tree
Showing 54 changed files with 14,552 additions and 1 deletion.
26 changes: 26 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
DESTINATION_APPWRITE_TEST_PROJECT=testProject
DESTINATION_APPWRITE_TEST_ENDPOINT=http:https://localhost/v1
DESTINATION_APPWRITE_TEST_KEY=xxxxxxxxxxxxxxxxxx

SOURCE_APPWRITE_TEST_PROJECT=testProject
SOURCE_APPWRITE_TEST_ENDPOINT=http:https://localhost/v1
SOURCE_APPWRITE_TEST_KEY=xxxxxxxxxxxxxxxxxx

FIREBASE_TEST_PROJECT=testProject
FIREBASE_TEST_ACCOUNT='{type: "service_account", ...}'

SUPABASE_TEST_ENDPOINT=https://xxxxxxxxxxxx.supabase.co
SUPABASE_TEST_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
SUPABASE_TEST_HOST=db.xxxxxxxxxxxxxxxx.supabase.co
SUPABASE_TEST_DATABASE=postgres
SUPABASE_TEST_USERNAME=postgres
SUPABASE_TEST_PASSWORD=xxxxxxxxxxxxxxxxxxxxx

NHOST_TEST_SUBDOMAIN=xxxxxxxxxxx
NHOST_TEST_REGION=eu-central-1
NHOST_TEST_SECRET=xxxxxxxxxxxxxxxxx
NHOST_TEST_DATABASE=xxxxxxxxxxxxxxx
NHOST_TEST_USERNAME=postgres
NHOST_TEST_PASSWORD=xxxxxxxxxxxxxxx


10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
composer.lock
/vendor/
/.idea/
*.cache
.env
test-service-account.json
.DS_Store
localBackup/
.vscode/
.env.prod
76 changes: 76 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Contributor Covenant Code of Conduct

## Our Pledge

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to make participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity, expression,
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment
include:

- Using welcoming and inclusive language
- Being respectful of differing viewpoints and experiences
- Gracefully accepting constructive criticism
- Focusing on what is best for the community
- Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

- The use of sexualized language or imagery and unwelcome sexual attention or
advances
- Trolling, insulting/derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or electronic
address, without explicit permission
- Other conduct which could reasonably be considered inappropriate in a
professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.

## Scope

This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at [email protected]. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html

[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq
33 changes: 33 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
FROM postgres:alpine3.18 as supabase-db
COPY ./tests/Transfer/resources/supabase/backup.tar /docker-entrypoint-initdb.d/backup.tar
COPY ./tests/Transfer/resources/restore.sh /docker-entrypoint-initdb.d/restore.sh

FROM postgres:alpine3.18 as nhost-db
COPY ./tests/Transfer/resources/nhost/backup.tar /docker-entrypoint-initdb.d/backup.tar
COPY ./tests/Transfer/resources/restore.sh /docker-entrypoint-initdb.d/restore.sh

# Use my fork of mockoon while waiting for range headers to be merged
FROM node:14-alpine3.14 as mock-api
WORKDIR /app
RUN git clone https://github.com/PineappleIOnic/mockoon.git .
RUN npm run bootstrap
RUN npm run build:libs
RUN npm run build:cli
RUN mv ./packages/cli/dist/run /usr/local/bin/mockoon

FROM composer:2.0 as composer

WORKDIR /usr/local/src/

COPY composer.lock /usr/local/src/
COPY composer.json /usr/local/src/

RUN composer install --ignore-platform-reqs

FROM php:8.0-fpm-alpine3.14 as tests
RUN set -ex && apk --no-cache add postgresql-dev
RUN docker-php-ext-install pdo pdo_pgsql
COPY ./src /usr/local/src
COPY ./tests /usr/local/src/tests
COPY --from=composer /usr/local/src/vendor /usr/local/src/vendor
CMD php ./vendor/bin/phpunit
75 changes: 74 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,74 @@
# transfer
# Utopia Transfer

[![Build Status](https://travis-ci.com/utopia-php/transfer.svg?branch=main)](https://travis-ci.com/utopia-php/transfer)
![Total Downloads](https://img.shields.io/packagist/dt/utopia-php/transfer.svg)
[![Discord](https://img.shields.io/discord/564160730845151244?label=discord)](https://appwrite.io/discord)

Utopia Transfer is a simple and lite library to transfer and transform resources inbetween services. This library is aiming to be as simple and easy to learn and use. This library is maintained by the [Appwrite team](https://appwrite.io).

Although this library is part of the [Utopia Framework](https://github.com/utopia-php/framework) project it is dependency free and can be used as standalone with any other PHP project or framework.

## Getting Started

Install using composer:
```bash
composer require utopia-php/transfer
```

Init in your application:
```php
<?php

use Utopia\Transfer\Transfer;
use Utopia\Transfer\Sources\NHost;
use Utopia\Transfer\Destinations\Appwrite;

require_once __DIR__ . '/../../vendor/autoload.php';

// Initialize your Source
$source = new NHost('db.xxxxxxxxx.nhost.run', 'database-name', 'username', 'password');

// Initialize your Destination
$destination = new Appwrite('project-id', 'https://cloud.appwrite.io/v1', 'api-key');

// Initialize Transfer
$transfer = new Transfer($source, $destination);

// Transfer the resource groups you want
$transfer->run(
[
Transfer::GROUP_AUTH
], function ($status) {
echo $status['message'] . PHP_EOL;
}
);
```

## Supported Resources Chart

Sources:
| | Auth | Databases | Storage | Functions | Settings |
|----------|-------|-----------|-------|-----------|-----------|
| Appwrite ||||| |
| Supabase |||| | |
| NHost |||| | |
| Firebase |||| | |

Destinations:
| | Auth | Databases | Storage | Functions | Settings |
|----------|-------|-----------|-------|-----------|-----------|
| Appwrite ||||| |
| Local ||||||

> **Warning**
> The Local destination should be used for testing purposes only. It is not recommended to use this destination in production or as a backup. The local destination is there to confirm that a source is working correctly and to test the transfer process with needing a target destination instance. This may change in the future however as the library matures.


## System Requirements

Utopia Transfer requires PHP 8.0 or later. We recommend using the latest PHP version whenever possible.

## Copyright and license

The MIT License (MIT) [http:https://www.opensource.org/licenses/mit-license.php](http:https://www.opensource.org/licenses/mit-license.php)
35 changes: 35 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name": "utopia-php/transfer",
"description": "A simple library to transfer resources between services.",
"type": "library",
"keywords": ["php", "framework", "upf", "utopia", "transfer"],
"license": "MIT",
"minimum-stability": "stable",
"authors": [{
"name": "Eldad Fux",
"email": "[email protected]"
},
{
"name": "Bradley Schofield",
"email": "[email protected]"
}
],
"autoload": {
"psr-4": {
"Utopia\\Transfer\\": "src/Transfer"
}
},
"autoload-dev": {
"psr-4": {"Utopia\\Tests\\": "tests/Transfer"}
},
"require": {
"php": ">=8.0",
"utopia-php/cli": "^0.13.0",
"appwrite/appwrite": "^8.0"
},
"require-dev": {
"phpunit/phpunit": "^9.3",
"vlucas/phpdotenv": "^5.5",
"laravel/pint": "^1.10"
}
}
47 changes: 47 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
version: '3'

services:
supabase-db:
build:
context: .
target: supabase-db
ports:
- "5432:5432"
networks:
- tests
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres

nhost-db:
build:
context: .
target: nhost-db
networks:
- tests
ports:
- "5433:5432"
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres

tests:
build:
context: .
target: tests
networks:
- tests
volumes:
- ./:/app
working_dir: /app
depends_on:
- supabase-db
- nhost-db
environment:
- NHOST_DB_URL=postgres:https://postgres:postgres@nhost-db:5432/postgres
- SUPABASE_DB_URL=postgres:https://postgres:postgres@supabase-db:5432/postgres

networks:
tests:
15 changes: 15 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0"?>
<ruleset name="Appwrite Standard" namespace="Utopia">
<rule ref="PSR12"/>
<file>./src</file>
<file>./tests</file>
<ini name="memory_limit" value="4096M"/>
<!-- Ignore max line width -->
<rule ref="Generic.Files.LineLength">
<exclude-pattern>*</exclude-pattern>
</rule>
<!-- Allow Side Effects on root level of files -->
<rule ref="PSR1.Files.SideEffects.FoundWithSymbols">
<exclude-pattern>*</exclude-pattern>
</rule>
</ruleset>
16 changes: 16 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
>
<testsuites>
<testsuite name="E2E">
<directory>./tests/Transfer/E2E</directory>
</testsuite>
</testsuites>
</phpunit>
Loading

0 comments on commit 2acef10

Please sign in to comment.