Skip to content

Commit 23912c1

Browse files
authored
Merge pull request #232 from appwrite/dev
2 parents b6c69c3 + e498003 commit 23912c1

File tree

15 files changed

+162
-41
lines changed

15 files changed

+162
-41
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Change Log
22

3+
## 13.0.0-rc.5
4+
5+
- Fix Push all not working correctly
6+
37
## 13.0.0-rc.4
48

59
- Fix CLI ES module import issues

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Once the installation is complete, you can verify the install using
2929

3030
```sh
3131
$ appwrite -v
32-
13.0.0-rc.4
32+
13.0.0-rc.5
3333
```
3434

3535
### Install using prebuilt binaries
@@ -60,7 +60,7 @@ $ scoop install https://raw.githubusercontent.com/appwrite/sdk-for-cli/master/sc
6060
Once the installation completes, you can verify your install using
6161
```
6262
$ appwrite -v
63-
13.0.0-rc.4
63+
13.0.0-rc.5
6464
```
6565

6666
## Getting Started

install.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
# You can use "View source" of this page to see the full script.
1414

1515
# REPO
16-
$GITHUB_x64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/13.0.0-rc.4/appwrite-cli-win-x64.exe"
17-
$GITHUB_arm64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/13.0.0-rc.4/appwrite-cli-win-arm64.exe"
16+
$GITHUB_x64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/13.0.0-rc.5/appwrite-cli-win-x64.exe"
17+
$GITHUB_arm64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/13.0.0-rc.5/appwrite-cli-win-arm64.exe"
1818

1919
$APPWRITE_BINARY_NAME = "appwrite.exe"
2020

install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ printSuccess() {
9696
downloadBinary() {
9797
echo "[2/4] Downloading executable for $OS ($ARCH) ..."
9898

99-
GITHUB_LATEST_VERSION="13.0.0-rc.4"
99+
GITHUB_LATEST_VERSION="13.0.0-rc.5"
100100
GITHUB_FILE="appwrite-cli-${OS}-${ARCH}"
101101
GITHUB_URL="https://github.com/$GITHUB_REPOSITORY_NAME/releases/download/$GITHUB_LATEST_VERSION/$GITHUB_FILE"
102102

lib/client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import {
1919
SDK_TITLE,
2020
} from "./constants.js";
2121

22-
const JSONBigInt = JSONbig({ storeAsString: false });
22+
const JSONBigInt = JSONbig({ useNativeBigInt: true });
2323

2424
class Client {
2525
private endpoint: string;

lib/commands/config.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,10 @@ const SettingsSchema = z
127127
.optional(),
128128
security: z
129129
.object({
130-
duration: z.number().optional(),
131-
limit: z.number().optional(),
132-
sessionsLimit: z.number().optional(),
133-
passwordHistory: z.number().optional(),
130+
duration: z.union([z.number(), z.bigint()]).optional(),
131+
limit: z.union([z.number(), z.bigint()]).optional(),
132+
sessionsLimit: z.union([z.number(), z.bigint()]).optional(),
133+
passwordHistory: z.union([z.number(), z.bigint()]).optional(),
134134
passwordDictionary: z.boolean().optional(),
135135
personalDataCheck: z.boolean().optional(),
136136
sessionAlerts: z.boolean().optional(),
@@ -155,7 +155,7 @@ const SiteSchema = z
155155
name: z.string(),
156156
enabled: z.boolean().optional(),
157157
logging: z.boolean().optional(),
158-
timeout: z.number().optional(),
158+
timeout: z.union([z.number(), z.bigint()]).optional(),
159159
framework: z.string().optional(),
160160
buildRuntime: z.string().optional(),
161161
adapter: z.string().optional(),
@@ -182,7 +182,7 @@ const FunctionSchema = z
182182
scopes: z.array(z.string()).optional(),
183183
events: z.array(z.string()).optional(),
184184
schedule: z.string().optional(),
185-
timeout: z.number().optional(),
185+
timeout: z.union([z.number(), z.bigint()]).optional(),
186186
entrypoint: z.string().optional(),
187187
commands: z.string().optional(),
188188
vars: z.record(z.string(), z.string()).optional(),

lib/commands/push.ts

Lines changed: 106 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import fs from "fs";
2+
import path from "path";
23
import { parse as parseDotenv } from "dotenv";
34
import chalk from "chalk";
45
import inquirer from "inquirer";
@@ -25,7 +26,9 @@ import {
2526
questionsPushBuckets,
2627
questionsPushTeams,
2728
questionsPushFunctions,
29+
questionsPushFunctionsCode,
2830
questionsPushSites,
31+
questionsPushSitesCode,
2932
questionsGetEntrypoint,
3033
questionsPushCollections,
3134
questionsPushTables,
@@ -414,23 +417,23 @@ export class Push {
414417
this.log("Applying auth security settings ...");
415418
await projectsService.updateAuthDuration({
416419
projectId,
417-
duration: settings.auth.security.duration,
420+
duration: Number(settings.auth.security.duration),
418421
});
419422
await projectsService.updateAuthLimit({
420423
projectId,
421-
limit: settings.auth.security.limit,
424+
limit: Number(settings.auth.security.limit),
422425
});
423426
await projectsService.updateAuthSessionsLimit({
424427
projectId,
425-
limit: settings.auth.security.sessionsLimit,
428+
limit: Number(settings.auth.security.sessionsLimit),
426429
});
427430
await projectsService.updateAuthPasswordDictionary({
428431
projectId,
429432
enabled: settings.auth.security.passwordDictionary,
430433
});
431434
await projectsService.updateAuthPasswordHistory({
432435
projectId,
433-
limit: settings.auth.security.passwordHistory,
436+
limit: Number(settings.auth.security.passwordHistory),
434437
});
435438
await projectsService.updatePersonalDataCheck({
436439
projectId,
@@ -807,6 +810,27 @@ export class Push {
807810
return;
808811
}
809812

813+
if (!func.path) {
814+
errors.push(new Error(`Function '${func.name}' has no path configured`));
815+
updaterRow.fail({
816+
errorMessage: `No path configured for function`,
817+
});
818+
return;
819+
}
820+
821+
if (
822+
!fs.existsSync(func.path) ||
823+
fs.readdirSync(func.path).length === 0
824+
) {
825+
errors.push(
826+
new Error(`Deployment not found or empty at path: ${func.path}`),
827+
);
828+
updaterRow.fail({
829+
errorMessage: `path not found or empty: ${path.relative(process.cwd(), path.resolve(func.path))}`,
830+
});
831+
return;
832+
}
833+
810834
try {
811835
updaterRow.update({ status: "Pushing" }).replaceSpinner(SPINNER_DOTS);
812836
const functionsServiceDeploy = await getFunctionsService(
@@ -838,7 +862,7 @@ export class Push {
838862
switch (e.code) {
839863
case "ENOENT":
840864
updaterRow.fail({
841-
errorMessage: "Not found in the current directory. Skipping...",
865+
errorMessage: `Deployment not found at path: ${path.resolve(func.path)}`,
842866
});
843867
break;
844868
default:
@@ -1145,6 +1169,27 @@ export class Push {
11451169
return;
11461170
}
11471171

1172+
if (!site.path) {
1173+
errors.push(new Error(`Site '${site.name}' has no path configured`));
1174+
updaterRow.fail({
1175+
errorMessage: `No path configured for site`,
1176+
});
1177+
return;
1178+
}
1179+
1180+
if (
1181+
!fs.existsSync(site.path) ||
1182+
fs.readdirSync(site.path).length === 0
1183+
) {
1184+
errors.push(
1185+
new Error(`Deployment not found or empty at path: ${site.path}`),
1186+
);
1187+
updaterRow.fail({
1188+
errorMessage: `path not found or empty: ${path.relative(process.cwd(), path.resolve(site.path))}`,
1189+
});
1190+
return;
1191+
}
1192+
11481193
try {
11491194
updaterRow.update({ status: "Pushing" }).replaceSpinner(SPINNER_DOTS);
11501195
const sitesServiceDeploy = await getSitesService(this.projectClient);
@@ -1174,7 +1219,7 @@ export class Push {
11741219
switch (e.code) {
11751220
case "ENOENT":
11761221
updaterRow.fail({
1177-
errorMessage: "Not found in the current directory. Skipping...",
1222+
errorMessage: `Deployment not found at path: ${path.resolve(site.path)}`,
11781223
});
11791224
break;
11801225
default:
@@ -1593,13 +1638,47 @@ const pushResources = async ({
15931638
if (cliConfig.all) {
15941639
checkDeployConditions(localConfig);
15951640

1641+
const functions = localConfig.getFunctions();
1642+
let allowFunctionsCodePush: boolean | null =
1643+
cliConfig.force === true ? true : null;
1644+
if (functions.length > 0 && allowFunctionsCodePush === null) {
1645+
const codeAnswer = await inquirer.prompt(questionsPushFunctionsCode);
1646+
allowFunctionsCodePush = codeAnswer.override;
1647+
}
1648+
1649+
const sites = localConfig.getSites();
1650+
let allowSitesCodePush: boolean | null =
1651+
cliConfig.force === true ? true : null;
1652+
if (sites.length > 0 && allowSitesCodePush === null) {
1653+
const codeAnswer = await inquirer.prompt(questionsPushSitesCode);
1654+
allowSitesCodePush = codeAnswer.override;
1655+
}
1656+
15961657
const pushInstance = await createPushInstance();
1597-
const config = localConfig.getProject() as ConfigType;
1658+
const project = localConfig.getProject();
1659+
const config: ConfigType = {
1660+
projectId: project.projectId ?? "",
1661+
projectName: project.projectName,
1662+
settings: project.projectSettings,
1663+
functions,
1664+
sites,
1665+
collections: localConfig.getCollections(),
1666+
databases: localConfig.getDatabases(),
1667+
tables: localConfig.getTables(),
1668+
tablesDB: localConfig.getTablesDBs(),
1669+
buckets: localConfig.getBuckets(),
1670+
teams: localConfig.getTeams(),
1671+
topics: localConfig.getMessagingTopics(),
1672+
};
15981673

15991674
await pushInstance.pushResources(config, {
1675+
all: cliConfig.all,
16001676
skipDeprecated,
1601-
functionOptions: { code: true, withVariables: false },
1602-
siteOptions: { code: true, withVariables: false },
1677+
functionOptions: {
1678+
code: allowFunctionsCodePush === true,
1679+
withVariables: false,
1680+
},
1681+
siteOptions: { code: allowSitesCodePush === true, withVariables: false },
16031682
});
16041683
} else {
16051684
const actions: Record<string, (options?: any) => Promise<void>> = {
@@ -1763,12 +1842,20 @@ const pushSite = async ({
17631842
return;
17641843
}
17651844

1845+
let allowCodePush: boolean | null = cliConfig.force === true ? true : null;
1846+
if (code !== false && allowCodePush === null) {
1847+
const codeAnswer = await inquirer.prompt(questionsPushSitesCode);
1848+
allowCodePush = codeAnswer.override;
1849+
}
1850+
1851+
const shouldPushCode = code !== false && allowCodePush === true;
1852+
17661853
log("Pushing sites ...");
17671854

17681855
const pushInstance = await createPushInstance();
17691856
const result = await pushInstance.pushSites(sites, {
17701857
async: asyncDeploy,
1771-
code,
1858+
code: shouldPushCode,
17721859
withVariables,
17731860
});
17741861

@@ -1883,12 +1970,20 @@ const pushFunction = async ({
18831970
return;
18841971
}
18851972

1973+
let allowCodePush: boolean | null = cliConfig.force === true ? true : null;
1974+
if (code !== false && allowCodePush === null) {
1975+
const codeAnswer = await inquirer.prompt(questionsPushFunctionsCode);
1976+
allowCodePush = codeAnswer.override;
1977+
}
1978+
1979+
const shouldPushCode = code !== false && allowCodePush === true;
1980+
18861981
log("Pushing functions ...");
18871982

18881983
const pushInstance = await createPushInstance();
18891984
const result = await pushInstance.pushFunctions(functions, {
18901985
async: asyncDeploy,
1891-
code,
1986+
code: shouldPushCode,
18921987
withVariables,
18931988
});
18941989

lib/commands/schema.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import * as fs from "fs";
99
import * as path from "path";
1010
import { Db } from "./db.js";
1111

12-
const JSONBig = JSONbig({ storeAsString: false });
12+
const JSONBig = JSONbig({ useNativeBigInt: true });
1313

1414
export class Schema {
1515
private pullCommand: Pull;

lib/commands/utils/attributes.ts

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import chalk from "chalk";
22
import { getDatabasesService } from "../../services.js";
33
import { KeysAttributes } from "../../config.js";
4-
import { log, success, cliConfig, drawTable } from "../../parser.js";
4+
import { log, success, error, cliConfig, drawTable } from "../../parser.js";
55
import { Pools } from "./pools.js";
66
import inquirer from "inquirer";
77

@@ -591,15 +591,21 @@ export class Attributes {
591591

592592
if (changes.length > 0) {
593593
changedAttributes = changes.map((change) => change.attribute);
594-
await Promise.all(
595-
changedAttributes.map((changed) =>
596-
this.updateAttribute(
597-
collection["databaseId"],
598-
collection["$id"],
599-
changed,
594+
try {
595+
await Promise.all(
596+
changedAttributes.map((changed) =>
597+
this.updateAttribute(
598+
collection["databaseId"],
599+
collection["$id"],
600+
changed,
601+
),
600602
),
601-
),
602-
);
603+
);
604+
} catch (err) {
605+
error(
606+
`Error updating attribute for ${collection["$id"]}: ${String(err)}`,
607+
);
608+
}
603609
}
604610

605611
const deletingAttributes = deleting.map((change) => change.attribute);

lib/commands/utils/pools.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export class Pools {
4444
}
4545

4646
if (this.pollMaxDebounces === this.POLL_DEFAULT_VALUE) {
47-
let steps = Math.max(1, Math.ceil(total / this.STEP_SIZE));
47+
let steps = Math.max(1, Math.ceil(Number(total) / this.STEP_SIZE));
4848
if (steps > 1 && iteration === 1) {
4949
this.pollMaxDebounces *= steps;
5050

@@ -83,7 +83,7 @@ export class Pools {
8383
}
8484

8585
if (this.pollMaxDebounces === this.POLL_DEFAULT_VALUE) {
86-
let steps = Math.max(1, Math.ceil(total / this.STEP_SIZE));
86+
let steps = Math.max(1, Math.ceil(Number(total) / this.STEP_SIZE));
8787
if (steps > 1 && iteration === 1) {
8888
this.pollMaxDebounces *= steps;
8989

0 commit comments

Comments
 (0)