appwrite-cli 8.1.0 → 8.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Change Log
2
2
 
3
+ ## 8.1.1
4
+
5
+ * Fix circular dependency issue due to usage of `success` method in `utils.js` file from `parser.js` file
6
+ * Type generation fixes:
7
+ * Add ability to generate types directly to a specific file by passing a file path to `appwrite types output_path`, instead of just a directory
8
+ * Fix non-required attributes to not be null if default value is provided
9
+ * Fix `Models` import error
10
+ * Improve formatting and add auto-generated comments
11
+
3
12
  ## 8.1.0
4
13
 
5
14
  * Add multi-region support to `init` command
@@ -15,7 +24,7 @@
15
24
 
16
25
  * Add Type generation fixes:
17
26
  * Properly handle enum attributes in dart, java and kotlin
18
- * Fix initialisation of null attributes in dart's fromMap method
27
+ * Fix initialisation of null attributes in dart's fromMap method
19
28
  * Fix relationships and enums in swift
20
29
 
21
30
  ## 8.0.1
package/README.md CHANGED
@@ -29,7 +29,7 @@ Once the installation is complete, you can verify the install using
29
29
 
30
30
  ```sh
31
31
  $ appwrite -v
32
- 8.1.0
32
+ 8.1.1
33
33
  ```
34
34
 
35
35
  ### Install using prebuilt binaries
@@ -60,7 +60,7 @@ $ scoop install https://raw.githubusercontent.com/appwrite/sdk-for-cli/master/sc
60
60
  Once the installation completes, you can verify your install using
61
61
  ```
62
62
  $ appwrite -v
63
- 8.1.0
63
+ 8.1.1
64
64
  ```
65
65
 
66
66
  ## Getting Started
package/install.ps1 CHANGED
@@ -13,8 +13,8 @@
13
13
  # You can use "View source" of this page to see the full script.
14
14
 
15
15
  # REPO
16
- $GITHUB_x64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/8.1.0/appwrite-cli-win-x64.exe"
17
- $GITHUB_arm64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/8.1.0/appwrite-cli-win-arm64.exe"
16
+ $GITHUB_x64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/8.1.1/appwrite-cli-win-x64.exe"
17
+ $GITHUB_arm64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/8.1.1/appwrite-cli-win-arm64.exe"
18
18
 
19
19
  $APPWRITE_BINARY_NAME = "appwrite.exe"
20
20
 
package/install.sh CHANGED
@@ -97,7 +97,7 @@ printSuccess() {
97
97
  downloadBinary() {
98
98
  echo "[2/4] Downloading executable for $OS ($ARCH) ..."
99
99
 
100
- GITHUB_LATEST_VERSION="8.1.0"
100
+ GITHUB_LATEST_VERSION="8.1.1"
101
101
  GITHUB_FILE="appwrite-cli-${OS}-${ARCH}"
102
102
  GITHUB_URL="https://github.com/$GITHUB_REPOSITORY_NAME/releases/download/$GITHUB_LATEST_VERSION/$GITHUB_FILE"
103
103
 
package/lib/client.js CHANGED
@@ -16,8 +16,8 @@ class Client {
16
16
  'x-sdk-name': 'Command Line',
17
17
  'x-sdk-platform': 'console',
18
18
  'x-sdk-language': 'cli',
19
- 'x-sdk-version': '8.1.0',
20
- 'user-agent' : `AppwriteCLI/8.1.0 (${os.type()} ${os.version()}; ${os.arch()})`,
19
+ 'x-sdk-version': '8.1.1',
20
+ 'user-agent' : `AppwriteCLI/8.1.1 (${os.type()} ${os.version()}; ${os.arch()})`,
21
21
  'X-Appwrite-Response-Format' : '1.7.0',
22
22
  };
23
23
  }
@@ -66,7 +66,22 @@ const typesCommand = actionRunner(async (rawOutputDirectory, {language}) => {
66
66
 
67
67
  const meta = createLanguageMeta(language);
68
68
 
69
- const outputDirectory = path.resolve(rawOutputDirectory);
69
+ const rawOutputPath = rawOutputDirectory;
70
+ const outputExt = path.extname(rawOutputPath);
71
+ const isFileOutput = !!outputExt;
72
+ let outputDirectory = rawOutputPath;
73
+ let singleFileDestination = null;
74
+
75
+ if (isFileOutput) {
76
+ if (meta.isSingleFile()) {
77
+ // Use the file path directly for single file languages
78
+ outputDirectory = path.dirname(rawOutputPath);
79
+ singleFileDestination = rawOutputPath;
80
+ } else {
81
+ throw new Error(`Invalid output path: ${rawOutputPath}. Output path must be a directory for languages that generate multiple files.`);
82
+ }
83
+ }
84
+
70
85
  if (!fs.existsSync(outputDirectory)) {
71
86
  log(`Directory: ${outputDirectory} does not exist, creating...`);
72
87
  fs.mkdirSync(outputDirectory, { recursive: true });
@@ -95,7 +110,7 @@ const typesCommand = actionRunner(async (rawOutputDirectory, {language}) => {
95
110
  getType: meta.getType
96
111
  });
97
112
 
98
- const destination = path.join(outputDirectory, meta.getFileName());
113
+ const destination = singleFileDestination || path.join(outputDirectory, meta.getFileName());
99
114
 
100
115
  fs.writeFileSync(destination, content);
101
116
  log(`Added types to ${destination}`);
package/lib/parser.js CHANGED
@@ -120,7 +120,7 @@ const parseError = (err) => {
120
120
  } catch {
121
121
  }
122
122
 
123
- const version = '8.1.0';
123
+ const version = '8.1.1';
124
124
  const stepsToReproduce = `Running \`appwrite ${cliConfig.reportData.data.args.join(' ')}\``;
125
125
  const yourEnvironment = `CLI version: ${version}\nOperation System: ${os.type()}\nAppwrite version: ${appwriteVersion}\nIs Cloud: ${isCloud()}`;
126
126
 
@@ -41,6 +41,10 @@ class Dart extends LanguageMeta {
41
41
  return type;
42
42
  }
43
43
 
44
+ getCurrentDirectory() {
45
+ return process.cwd();
46
+ }
47
+
44
48
  getTemplate() {
45
49
  return `<% for (const attribute of collection.attributes) { -%>
46
50
  <% if (attribute.type === 'relationship') { -%>
@@ -48,11 +52,16 @@ import '<%- attribute.relatedCollection.toLowerCase() %>.dart';
48
52
 
49
53
  <% } -%>
50
54
  <% } -%>
55
+ /**
56
+ * This file is auto-generated by the Appwrite CLI.
57
+ * You can regenerate it by running \`appwrite types -l dart ${this.getCurrentDirectory()}\`.
58
+ */
59
+
51
60
  <% for (const attribute of collection.attributes) { -%>
52
61
  <% if (attribute.format === 'enum') { -%>
53
62
  enum <%- toPascalCase(attribute.key) %> {
54
- <% for (const element of attribute.elements) { -%>
55
- <%- toSnakeCase(element) %>,
63
+ <% for (const [index, element] of Object.entries(attribute.elements)) { -%>
64
+ <%- toSnakeCase(element) %><% if (index < attribute.elements.length - 1) { %>,<% } %>
56
65
  <% } -%>
57
66
  }
58
67
 
@@ -65,7 +74,7 @@ class <%= toPascalCase(collection.name) %> {
65
74
 
66
75
  <%= toPascalCase(collection.name) %>({
67
76
  <% for (const [index, attribute] of Object.entries(collection.attributes)) { -%>
68
- <% if (attribute.required) { %>required <% } %>this.<%= toCamelCase(attribute.key) %>,
77
+ <% if (attribute.required) { %>required <% } %>this.<%= toCamelCase(attribute.key) %><% if (index < collection.attributes.length - 1) { %>,<% } %>
69
78
  <% } -%>
70
79
  });
71
80
 
@@ -114,7 +123,7 @@ map['<%= attribute.key %>']<% if (!attribute.required) { %> ?? null<% } -%>
114
123
  map['<%= attribute.key %>'] != null ? <%- toPascalCase(attribute.relatedCollection) %>.fromMap(map['<%= attribute.key %>']) : null<% } else { -%>
115
124
  <%- toPascalCase(attribute.relatedCollection) %>.fromMap(map['<%= attribute.key %>'])<% } -%>
116
125
  <% } -%>
117
- <% } -%>,
126
+ <% } -%><% if (index < collection.attributes.length - 1) { %>,<% } %>
118
127
  <% } -%>
119
128
  );
120
129
  }
@@ -136,7 +145,7 @@ map['<%= attribute.key %>'] != null ? <%- toPascalCase(attribute.relatedCollecti
136
145
  <% } -%>
137
146
  <% } else { -%>
138
147
  <%= toCamelCase(attribute.key) -%>
139
- <% } -%>,
148
+ <% } -%><% if (index < collection.attributes.length - 1) { %>,<% } %>
140
149
  <% } -%>
141
150
  };
142
151
  }
@@ -38,9 +38,18 @@ class Java extends LanguageMeta {
38
38
  return type;
39
39
  }
40
40
 
41
+ getCurrentDirectory() {
42
+ return process.cwd();
43
+ }
44
+
41
45
  getTemplate() {
42
46
  return `package io.appwrite.models;
43
47
 
48
+ /**
49
+ * This file is auto-generated by the Appwrite CLI.
50
+ * You can regenerate it by running \`appwrite types -l java ${this.getCurrentDirectory()}\`.
51
+ */
52
+
44
53
  import java.util.*;
45
54
  <% for (const attribute of collection.attributes) { -%>
46
55
  <% if (attribute.type === 'relationship') { -%>
@@ -40,8 +40,8 @@ class JavaScript extends LanguageMeta {
40
40
  if (attribute.array) {
41
41
  type += "[]";
42
42
  }
43
- if (!attribute.required) {
44
- type += "|null|undefined";
43
+ if (!attribute.required && attribute.default === null) {
44
+ type += "|null";
45
45
  }
46
46
  return type;
47
47
  }
@@ -60,11 +60,19 @@ class JavaScript extends LanguageMeta {
60
60
  return "appwrite";
61
61
  }
62
62
 
63
+ getCurrentDirectory() {
64
+ return process.cwd();
65
+ }
66
+
63
67
  getTemplate() {
64
68
  return `/**
65
69
  * @typedef {import('${this._getAppwriteDependency()}').Models.Document} Document
66
70
  */
67
71
 
72
+ /**
73
+ * This file is auto-generated by the Appwrite CLI.
74
+ * You can regenerate it by running \`appwrite types -l js ${this.getCurrentDirectory()}\`.
75
+ */
68
76
  <% for (const collection of collections) { %>
69
77
  /**
70
78
  * @typedef {Object} <%- toPascalCase(collection.name) %>
@@ -72,7 +80,6 @@ class JavaScript extends LanguageMeta {
72
80
  * @property {<%- getType(attribute) %>} <%- toCamelCase(attribute.key) %>
73
81
  <% } -%>
74
82
  */
75
-
76
83
  <% } %>`;
77
84
  }
78
85
 
@@ -35,12 +35,16 @@ class Kotlin extends LanguageMeta {
35
35
  if (attribute.array) {
36
36
  type = "List<" + type + ">";
37
37
  }
38
- if (!attribute.required) {
38
+ if (!attribute.required && attribute.default === null) {
39
39
  type += "?";
40
40
  }
41
41
  return type;
42
42
  }
43
43
 
44
+ getCurrentDirectory() {
45
+ return process.cwd();
46
+ }
47
+
44
48
  getTemplate() {
45
49
  return `package io.appwrite.models
46
50
 
@@ -50,6 +54,11 @@ import <%- toPascalCase(attribute.relatedCollection) %>
50
54
 
51
55
  <% } -%>
52
56
  <% } -%>
57
+ /**
58
+ * This file is auto-generated by the Appwrite CLI.
59
+ * You can regenerate it by running \`appwrite types -l kotlin ${this.getCurrentDirectory()}\`.
60
+ */
61
+
53
62
  <% for (const attribute of collection.attributes) { -%>
54
63
  <% if (attribute.format === 'enum') { -%>
55
64
  enum class <%- toPascalCase(attribute.key) %> {
@@ -61,8 +70,8 @@ enum class <%- toPascalCase(attribute.key) %> {
61
70
  <% } -%>
62
71
  <% } -%>
63
72
  data class <%- toPascalCase(collection.name) %>(
64
- <% for (const attribute of collection.attributes) { -%>
65
- val <%- toCamelCase(attribute.key) %>: <%- getType(attribute) %>,
73
+ <% for (const [index, attribute] of Object.entries(collection.attributes)) { -%>
74
+ val <%- toCamelCase(attribute.key) %>: <%- getType(attribute) %><% if (index < collection.attributes.length - 1) { %>,<% } %>
66
75
  <% } -%>
67
76
  )`;
68
77
  }
@@ -35,16 +35,25 @@ class PHP extends LanguageMeta {
35
35
  default:
36
36
  throw new Error(`Unknown attribute type: ${attribute.type}`);
37
37
  }
38
- if (!attribute.required) {
38
+ if (!attribute.required && attribute.default === null) {
39
39
  type += "|null";
40
40
  }
41
41
  return type;
42
42
  }
43
43
 
44
+ getCurrentDirectory() {
45
+ return process.cwd();
46
+ }
47
+
44
48
  getTemplate() {
45
49
  return `<?php
46
50
  namespace Appwrite\\Models;
47
51
 
52
+ /**
53
+ * This file is auto-generated by the Appwrite CLI.
54
+ * You can regenerate it by running \`appwrite types -l php ${this.getCurrentDirectory()}\`.
55
+ */
56
+
48
57
  <% for (const attribute of collection.attributes) { -%>
49
58
  <% if (attribute.type === 'relationship' && !(attribute.relationType === 'manyToMany') && !(attribute.relationType === 'oneToMany' && attribute.side === 'parent')) { -%>
50
59
  use Appwrite\\Models\\<%- toPascalCase(attribute.relatedCollection) %>;
@@ -35,15 +35,22 @@ class Swift extends LanguageMeta {
35
35
  if (attribute.array) {
36
36
  type = "[" + type + "]";
37
37
  }
38
- if (!attribute.required) {
38
+ if (!attribute.required && attribute.default === null) {
39
39
  type += "?";
40
40
  }
41
41
  return type;
42
42
  }
43
43
 
44
+ getCurrentDirectory() {
45
+ return process.cwd();
46
+ }
47
+
44
48
  getTemplate() {
45
49
  return `import Foundation
46
50
 
51
+ /// This file is auto-generated by the Appwrite CLI.
52
+ /// You can regenerate it by running \`appwrite types -l swift ${this.getCurrentDirectory()}\`.
53
+
47
54
  <% for (const attribute of collection.attributes) { -%>
48
55
  <% if (attribute.format === 'enum') { -%>
49
56
  public enum <%- toPascalCase(attribute.key) %>: String, Codable, CaseIterable {
@@ -40,7 +40,7 @@ class TypeScript extends LanguageMeta {
40
40
  if (attribute.array) {
41
41
  type += "[]";
42
42
  }
43
- if (!attribute.required) {
43
+ if (!attribute.required && attribute.default === null) {
44
44
  type += " | null";
45
45
  }
46
46
  return type;
@@ -64,15 +64,25 @@ class TypeScript extends LanguageMeta {
64
64
  return "appwrite";
65
65
  }
66
66
 
67
+ getCurrentDirectory() {
68
+ return process.cwd();
69
+ }
70
+
67
71
  getTemplate() {
68
- return `import { Models } from '${this._getAppwriteDependency()}';
72
+ return `import { type Models } from '${this._getAppwriteDependency()}';
73
+
74
+ /**
75
+ * This file is auto-generated by the Appwrite CLI.
76
+ * You can regenerate it by running \`appwrite types -l ts ${this.getCurrentDirectory()}\`.
77
+ */
69
78
 
70
79
  <% for (const collection of collections) { -%>
71
80
  <% for (const attribute of collection.attributes) { -%>
72
81
  <% if (attribute.format === 'enum') { -%>
73
82
  export enum <%- toPascalCase(attribute.key) %> {
74
- <% for (const [index, element] of Object.entries(attribute.elements)) { -%>
75
- <%- toUpperSnakeCase(element) %> = "<%- element %>",
83
+ <% const entries = Object.entries(attribute.elements); -%>
84
+ <% for (let i = 0; i < entries.length; i++) { -%>
85
+ <%- toUpperSnakeCase(entries[i][1]) %> = "<%- entries[i][1] %>"<% if (i !== entries.length - 1) { %>,<% } %>
76
86
  <% } -%>
77
87
  }
78
88
 
package/lib/utils.js CHANGED
@@ -2,8 +2,8 @@ const fs = require("fs");
2
2
  const path = require("path");
3
3
  const net = require("net");
4
4
  const childProcess = require('child_process');
5
+ const chalk = require('chalk');
5
6
  const { localConfig, globalConfig } = require("./config");
6
- const { success } = require('./parser')
7
7
 
8
8
  function getAllFiles(folder) {
9
9
  const files = [];
@@ -105,8 +105,7 @@ function showConsoleLink(serviceName, action, ...ids) {
105
105
  return;
106
106
  }
107
107
 
108
-
109
- success(url);
108
+ console.log(`${chalk.green.bold("✓ Success:")} ${chalk.green(url)}`);
110
109
  }
111
110
 
112
111
  function getAccountPath(action) {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "appwrite-cli",
3
3
  "homepage": "https://appwrite.io/support",
4
4
  "description": "Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API",
5
- "version": "8.1.0",
5
+ "version": "8.1.1",
6
6
  "license": "BSD-3-Clause",
7
7
  "main": "index.js",
8
8
  "bin": {
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "$schema": "https://raw.githubusercontent.com/ScoopInstaller/Scoop/master/schema.json",
3
- "version": "8.1.0",
3
+ "version": "8.1.1",
4
4
  "description": "The Appwrite CLI is a command-line application that allows you to interact with Appwrite and perform server-side tasks using your terminal.",
5
5
  "homepage": "https://github.com/appwrite/sdk-for-cli",
6
6
  "license": "BSD-3-Clause",
7
7
  "architecture": {
8
8
  "64bit": {
9
- "url": "https://github.com/appwrite/sdk-for-cli/releases/download/8.1.0/appwrite-cli-win-x64.exe",
9
+ "url": "https://github.com/appwrite/sdk-for-cli/releases/download/8.1.1/appwrite-cli-win-x64.exe",
10
10
  "bin": [
11
11
  [
12
12
  "appwrite-cli-win-x64.exe",
@@ -15,7 +15,7 @@
15
15
  ]
16
16
  },
17
17
  "arm64": {
18
- "url": "https://github.com/appwrite/sdk-for-cli/releases/download/8.1.0/appwrite-cli-win-arm64.exe",
18
+ "url": "https://github.com/appwrite/sdk-for-cli/releases/download/8.1.1/appwrite-cli-win-arm64.exe",
19
19
  "bin": [
20
20
  [
21
21
  "appwrite-cli-win-arm64.exe",