Skip to content

Commit

Permalink
Merge branch 'refs/heads/feat-cli-g2' into feat-create-resources
Browse files Browse the repository at this point in the history
# Conflicts:
#	templates/cli/lib/commands/push.js.twig
  • Loading branch information
byawitz committed May 29, 2024
2 parents 569a24b + 26054b2 commit f0be8ee
Show file tree
Hide file tree
Showing 57 changed files with 571 additions and 352 deletions.
35 changes: 34 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,40 @@ jobs:
fail-fast: false
matrix:
php-version: ['8.2']
sdk: [Android5Java17, Android14Java17, CLINode16, CLINode18, DartBeta, DartStable, Deno1193, Deno1303, DotNet60, DotNet70, FlutterStable, FlutterBeta, Go112, Go118, KotlinJava8, KotlinJava11, KotlinJava17, Node16, Node18, Node20, PHP74, PHP80, Python38, Python39, Python310, Ruby27, Ruby30, Ruby31, AppleSwift56, Swift56, WebChromium, WebNode]
sdk: [
Android5Java17,
Android14Java17,
CLINode16,
CLINode18,
DartBeta,
DartStable,
Deno1193,
Deno1303,
DotNet60,
DotNet80,
FlutterStable,
FlutterBeta,
Go112,
Go118,
KotlinJava8,
KotlinJava11,
KotlinJava17,
Node16,
Node18,
Node20,
PHP74,
PHP80,
Python38,
Python39,
Python310,
Ruby27,
Ruby30,
Ruby31,
AppleSwift56,
Swift56,
WebChromium,
WebNode
]

steps:
- name: Checkout repository
Expand Down
2 changes: 0 additions & 2 deletions mock-server/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: '3'

services:
mockapi:
container_name: mockapi
Expand Down
9 changes: 7 additions & 2 deletions src/SDK/Language/Dart.php
Original file line number Diff line number Diff line change
Expand Up @@ -475,8 +475,13 @@ public function getFiles(): array
],
[
'scope' => 'default',
'destination' => '.travis.yml',
'template' => 'dart/.travis.yml.twig',
'destination' => '.github/workflows/publish.yml',
'template' => 'dart/.github/workflows/publish.yml.twig',
],
[
'scope' => 'default',
'destination' => '.github/workflows/format.yml',
'template' => 'dart/.github/workflows/format.yml.twig',
],
[
'scope' => 'default',
Expand Down
76 changes: 38 additions & 38 deletions src/SDK/Language/DotNet.php
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,8 @@ public function getFiles(): array
return [
[
'scope' => 'default',
'destination' => '.travis.yml',
'template' => 'dotnet/.travis.yml.twig',
'destination' => '.github/workflows/publish.yml',
'template' => 'dotnet/.github/workflows/publish.yml.twig',
],
[
'scope' => 'default',
Expand Down Expand Up @@ -333,93 +333,93 @@ public function getFiles(): array
],
[
'scope' => 'default',
'destination' => '/src/{{ spec.title | caseUcfirst }}.sln',
'template' => 'dotnet/src/Appwrite.sln',
'destination' => '{{ spec.title | caseUcfirst }}.sln',
'template' => 'dotnet/Package.sln',
],
[
'scope' => 'default',
'destination' => '/src/{{ spec.title | caseUcfirst }}/{{ spec.title | caseUcfirst }}.csproj',
'template' => 'dotnet/src/Appwrite/Appwrite.csproj.twig',
'destination' => '{{ spec.title | caseUcfirst }}/{{ spec.title | caseUcfirst }}.csproj',
'template' => 'dotnet/Package/Package.csproj.twig',
],
[
'scope' => 'default',
'destination' => '/src/{{ spec.title | caseUcfirst }}/Client.cs',
'template' => 'dotnet/src/Appwrite/Client.cs.twig',
'destination' => '{{ spec.title | caseUcfirst }}/Client.cs',
'template' => 'dotnet/Package/Client.cs.twig',
],
[
'scope' => 'default',
'destination' => '/src/{{ spec.title | caseUcfirst }}/{{ spec.title | caseUcfirst }}Exception.cs',
'template' => 'dotnet/src/Appwrite/Exception.cs.twig',
'destination' => '{{ spec.title | caseUcfirst }}/{{ spec.title | caseUcfirst }}Exception.cs',
'template' => 'dotnet/Package/Exception.cs.twig',
],
[
'scope' => 'default',
'destination' => '/src/{{ spec.title | caseUcfirst }}/ID.cs',
'template' => 'dotnet/src/Appwrite/ID.cs.twig',
'destination' => '{{ spec.title | caseUcfirst }}/ID.cs',
'template' => 'dotnet/Package/ID.cs.twig',
],
[
'scope' => 'default',
'destination' => '/src/{{ spec.title | caseUcfirst }}/Permission.cs',
'template' => 'dotnet/src/Appwrite/Permission.cs.twig',
'destination' => '{{ spec.title | caseUcfirst }}/Permission.cs',
'template' => 'dotnet/Package/Permission.cs.twig',
],
[
'scope' => 'default',
'destination' => '/src/{{ spec.title | caseUcfirst }}/Query.cs',
'template' => 'dotnet/src/Appwrite/Query.cs.twig',
'destination' => '{{ spec.title | caseUcfirst }}/Query.cs',
'template' => 'dotnet/Package/Query.cs.twig',
],
[
'scope' => 'default',
'destination' => '/src/{{ spec.title | caseUcfirst }}/Role.cs',
'template' => 'dotnet/src/Appwrite/Role.cs.twig',
'destination' => '{{ spec.title | caseUcfirst }}/Role.cs',
'template' => 'dotnet/Package/Role.cs.twig',
],
[
'scope' => 'default',
'destination' => '/src/{{ spec.title | caseUcfirst }}/Converters/ValueClassConverter.cs',
'template' => 'dotnet/src/Appwrite/Converters/ValueClassConverter.cs.twig',
'destination' => '{{ spec.title | caseUcfirst }}/Converters/ValueClassConverter.cs',
'template' => 'dotnet/Package/Converters/ValueClassConverter.cs.twig',
],
[
'scope' => 'default',
'destination' => '/src/{{ spec.title | caseUcfirst }}/Extensions/Extensions.cs',
'template' => 'dotnet/src/Appwrite/Extensions/Extensions.cs.twig',
'destination' => '{{ spec.title | caseUcfirst }}/Extensions/Extensions.cs',
'template' => 'dotnet/Package/Extensions/Extensions.cs.twig',
],
[
'scope' => 'default',
'destination' => '/src/{{ spec.title | caseUcfirst }}/Models/OrderType.cs',
'template' => 'dotnet/src/Appwrite/Models/OrderType.cs.twig',
'destination' => '{{ spec.title | caseUcfirst }}/Models/OrderType.cs',
'template' => 'dotnet/Package/Models/OrderType.cs.twig',
],
[
'scope' => 'default',
'destination' => '/src/{{ spec.title | caseUcfirst }}/Models/UploadProgress.cs',
'template' => 'dotnet/src/Appwrite/Models/UploadProgress.cs.twig',
'destination' => '{{ spec.title | caseUcfirst }}/Models/UploadProgress.cs',
'template' => 'dotnet/Package/Models/UploadProgress.cs.twig',
],
[
'scope' => 'default',
'destination' => '/src/{{ spec.title | caseUcfirst }}/Models/InputFile.cs',
'template' => 'dotnet/src/Appwrite/Models/InputFile.cs.twig',
'destination' => '{{ spec.title | caseUcfirst }}/Models/InputFile.cs',
'template' => 'dotnet/Package/Models/InputFile.cs.twig',
],
[
'scope' => 'default',
'destination' => '/src/{{ spec.title | caseUcfirst }}/Services/Service.cs',
'template' => 'dotnet/src/Appwrite/Services/Service.cs.twig',
'destination' => '{{ spec.title | caseUcfirst }}/Services/Service.cs',
'template' => 'dotnet/Package/Services/Service.cs.twig',
],
[
'scope' => 'service',
'destination' => '/src/{{ spec.title | caseUcfirst }}/Services/{{service.name | caseUcfirst}}.cs',
'template' => 'dotnet/src/Appwrite/Services/ServiceTemplate.cs.twig',
'destination' => '{{ spec.title | caseUcfirst }}/Services/{{service.name | caseUcfirst}}.cs',
'template' => 'dotnet/Package/Services/ServiceTemplate.cs.twig',
],
[
'scope' => 'definition',
'destination' => '/src/{{ spec.title | caseUcfirst }}/Models/{{ definition.name | caseUcfirst | overrideIdentifier }}.cs',
'template' => 'dotnet/src/Appwrite/Models/Model.cs.twig',
'destination' => '{{ spec.title | caseUcfirst }}/Models/{{ definition.name | caseUcfirst | overrideIdentifier }}.cs',
'template' => 'dotnet/Package/Models/Model.cs.twig',
],
[
'scope' => 'enum',
'destination' => '/src/{{ spec.title | caseUcfirst }}/Enums/{{ enum.name | caseUcfirst | overrideIdentifier }}.cs',
'template' => 'dotnet/src/Appwrite/Enums/Enum.cs.twig',
'destination' => '{{ spec.title | caseUcfirst }}/Enums/{{ enum.name | caseUcfirst | overrideIdentifier }}.cs',
'template' => 'dotnet/Package/Enums/Enum.cs.twig',
],
[
'scope' => 'default',
'destination' => '/src/{{ spec.title | caseUcfirst }}/Enums/IEnum.cs',
'template' => 'dotnet/src/Appwrite/Enums/IEnum.cs.twig',
'destination' => '{{ spec.title | caseUcfirst }}/Enums/IEnum.cs',
'template' => 'dotnet/Package/Enums/IEnum.cs.twig',
]
];
}
Expand Down
9 changes: 7 additions & 2 deletions src/SDK/Language/Flutter.php
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,13 @@ public function getFiles(): array
],
[
'scope' => 'default',
'destination' => '.travis.yml',
'template' => 'flutter/.travis.yml.twig',
'destination' => '.github/workflows/publish.yml',
'template' => 'flutter/.github/workflows/publish.yml.twig',
],
[
'scope' => 'default',
'destination' => '.github/workflows/format.yml',
'template' => 'flutter/.github/workflows/format.yml.twig',
],
[
'scope' => 'enum',
Expand Down
4 changes: 2 additions & 2 deletions src/SDK/Language/Node.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,8 @@ public function getFiles(): array
],
[
'scope' => 'default',
'destination' => '.travis.yml',
'template' => 'node/.travis.yml.twig',
'destination' => '.github/workflows/publish.yml',
'template' => 'node/.github/workflows/publish.yml.twig',
],
[
'scope' => 'enum',
Expand Down
4 changes: 2 additions & 2 deletions src/SDK/Language/Python.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,8 @@ public function getFiles(): array
],
[
'scope' => 'default',
'destination' => '.travis.yml',
'template' => 'python/.travis.yml.twig',
'destination' => '.github/workflows/publish.yml',
'template' => 'python/.github/workflows/publish.yml.twig',
],
[
'scope' => 'enum',
Expand Down
4 changes: 2 additions & 2 deletions src/SDK/Language/Ruby.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ public function getFiles(): array
],
[
'scope' => 'default',
'destination' => '.travis.yml',
'template' => 'ruby/.travis.yml.twig',
'destination' => '.github/workflows/publish.yml',
'template' => 'ruby/.github/workflows/publish.yml.twig',
],
[
'scope' => 'definition',
Expand Down
4 changes: 2 additions & 2 deletions src/SDK/Language/Web.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ public function getFiles(): array
],
[
'scope' => 'default',
'destination' => '.travis.yml',
'template' => 'web/.travis.yml.twig',
'destination' => '.github/workflows/publish.yml',
'template' => 'web/.github/workflows/publish.yml.twig',
],
[
'scope' => 'enum',
Expand Down
2 changes: 1 addition & 1 deletion templates/apple/Package.swift.twig
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ let package = Package(
),
],
dependencies: [
.package(url: "https://github.com/swift-server/async-http-client.git", from: "1.9.0"),
.package(url: "https://github.com/swift-server/async-http-client.git", from: "1.17.0"),
.package(url: "https://github.com/apple/swift-nio.git", from: "2.32.0"),
],
targets: [
Expand Down
8 changes: 7 additions & 1 deletion templates/cli/lib/commands/push.js.twig
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@ const {
} = require("./messaging");
const {
teamsGet,
teamsUpdate,
teamsUpdateName,
teamsCreate
} = require("./teams");
const { projectsUpdate } = require("./projects");
const { checkDeployConditions } = require('../utils');

const STEP_SIZE = 100; // Resources
const POLL_DEBOUNCE = 2000; // Milliseconds
Expand Down Expand Up @@ -276,6 +277,7 @@ const pushFunction = async ({ functionId, all, yes, async } = {}) => {
if (functionId) {
functionIds.push(functionId);
} else if (all) {
checkDeployConditions(localConfig);
const functions = localConfig.getFunctions();
if (functions.length === 0) {
throw new Error("No functions found in the current directory.");
Expand Down Expand Up @@ -665,6 +667,7 @@ const pushCollection = async ({ all, yes } = {}) => {
const collections = [];

if (all) {
checkDeployConditions(localConfig);
if (localConfig.getCollections().length === 0) {
throw new Error("No collections found in the current directory. Run `{{ language.params.executableName }} pull collection` to fetch all your collections.");
}
Expand Down Expand Up @@ -887,6 +890,7 @@ const pushBucket = async ({ all, yes } = {}) => {
const configBuckets = localConfig.getBuckets();

if (all) {
checkDeployConditions(localConfig);
if (configBuckets.length === 0) {
throw new Error("No buckets found in the current directory. Run `appwrite pull bucket` to fetch all your buckets.");
}
Expand Down Expand Up @@ -974,6 +978,7 @@ const pushTeam = async ({ all, yes } = {}) => {
const configTeams = localConfig.getTeams();

if (all) {
checkDeployConditions(localConfig);
if (configTeams.length === 0) {
throw new Error("No teams found in the current directory. Run `appwrite pull team` to fetch all your teams.");
}
Expand Down Expand Up @@ -1045,6 +1050,7 @@ const pushMessagingTopic = async ({ all, yes } = {}) => {
let overrideExisting = yes;

if (all) {
checkDeployConditions(localConfig);
if (configTopics.length === 0) {
throw new Error("No topics found in the current directory. Run `appwrite pull topics` to pull all your messaging topics.");
}
Expand Down
6 changes: 6 additions & 0 deletions templates/cli/lib/questions.js.twig
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const { validateRequired } = require("./validations");
const { paginate } = require('./paginate');
const chalk = require('chalk');
const { databasesList } = require('./commands/databases');
const { checkDeployConditions } = require('./utils');
const JSONbig = require("json-bigint")({ storeAsString: false });

const whenOverride = (answers)=> answers.override === undefined ? true : answers.override;
Expand Down Expand Up @@ -445,6 +446,7 @@ const questionsPushFunctions = [
validate: (value) => validateRequired('function', value),
choices: () => {
let functions = localConfig.getFunctions();
checkDeployConditions(localConfig)
if (functions.length === 0) {
throw new Error("No functions found in the current directory.");
}
Expand Down Expand Up @@ -472,6 +474,8 @@ const questionsPushCollections = [
validate: (value) => validateRequired('collection', value),
choices: () => {
let collections = localConfig.getCollections();
checkDeployConditions(localConfig)

if (collections.length === 0) {
throw new Error("No collections found in the current directory. Run `{{ language.params.executableName }} pull collection` to fetch all your collections.");
}
Expand All @@ -498,6 +502,7 @@ const questionsPushBuckets = [
validate: (value) => validateRequired('bucket', value),
choices: () => {
let buckets = localConfig.getBuckets();
checkDeployConditions(localConfig)
if (buckets.length === 0) {
throw new Error("No buckets found in the current directory. Run `appwrite pull bucket` to fetch all your buckets.");
}
Expand Down Expand Up @@ -564,6 +569,7 @@ const questionsPushTeams = [
validate: (value) => validateRequired('team', value),
choices: () => {
let teams = localConfig.getTeams();
checkDeployConditions(localConfig);
if (teams.length === 0) {
throw new Error("No teams found in the current directory. Run `appwrite pull team` to fetch all your teams.");
}
Expand Down
9 changes: 8 additions & 1 deletion templates/cli/lib/utils.js.twig
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ function getAllFiles(folder) {
return files;
}

const checkDeployConditions = (localConfig) => {
if (Object.keys(localConfig.data).length === 0) {
throw new Error("No appwrite.json file found in the current directory. This command must be run in the folder holding your appwrite.json file. Please run this command again in the folder containing your appwrite.json file, or run appwrite init project.");
}
}

module.exports = {
getAllFiles
getAllFiles,
checkDeployConditions
};
Loading

0 comments on commit f0be8ee

Please sign in to comment.