appwrite-cli 13.3.2 → 13.5.0
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 +13 -0
- package/README.md +2 -2
- package/dist/bundle-win-arm64.mjs +1465 -3750
- package/dist/cli.cjs +1465 -3750
- package/dist/index.cjs +109626 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +904 -3243
- package/dist/lib/commands/generators/base.d.ts +16 -5
- package/dist/lib/commands/generators/base.d.ts.map +1 -1
- package/dist/lib/commands/generators/typescript/databases.d.ts.map +1 -1
- package/dist/lib/commands/push.d.ts +1 -0
- package/dist/lib/commands/push.d.ts.map +1 -1
- package/dist/lib/commands/utils/attributes.d.ts +3 -1
- package/dist/lib/commands/utils/attributes.d.ts.map +1 -1
- package/dist/lib/commands/utils/pools.d.ts +3 -1
- package/dist/lib/commands/utils/pools.d.ts.map +1 -1
- package/dist/lib/constants.d.ts +1 -1
- package/dist/lib/json.d.ts.map +1 -1
- package/dist/lib/utils.d.ts +1 -0
- package/dist/lib/utils.d.ts.map +1 -1
- package/docs/examples/projects/create-schedule.md +7 -0
- package/docs/examples/projects/get-schedule.md +5 -0
- package/docs/examples/projects/list-schedules.md +4 -0
- package/index.ts +1 -0
- package/install.ps1 +2 -2
- package/install.sh +1 -1
- package/lib/commands/generators/base.ts +30 -9
- package/lib/commands/generators/typescript/databases.ts +12 -18
- package/lib/commands/push.ts +294 -197
- package/lib/commands/services/databases.ts +32 -8
- package/lib/commands/services/migrations.ts +1 -1
- package/lib/commands/services/projects.ts +57 -4
- package/lib/commands/services/tables-db.ts +32 -8
- package/lib/commands/utils/attributes.ts +9 -6
- package/lib/commands/utils/pools.ts +9 -6
- package/lib/constants.ts +1 -1
- package/lib/json.ts +12 -2
- package/lib/utils.ts +15 -0
- package/package.json +19 -6
- package/scoop/appwrite.config.json +3 -3
package/lib/commands/push.ts
CHANGED
|
@@ -24,7 +24,11 @@ import {
|
|
|
24
24
|
type CollectionType,
|
|
25
25
|
} from "./config.js";
|
|
26
26
|
import { parseWithBetterErrors } from "./utils/error-formatter.js";
|
|
27
|
-
import {
|
|
27
|
+
import {
|
|
28
|
+
createSettingsObject,
|
|
29
|
+
checkDeployConditions,
|
|
30
|
+
arrayEqualsUnordered,
|
|
31
|
+
} from "../utils.js";
|
|
28
32
|
import { Spinner, SPINNER_DOTS } from "../spinner.js";
|
|
29
33
|
import { paginate } from "../paginate.js";
|
|
30
34
|
import { pushDeployment } from "./utils/deployment.js";
|
|
@@ -72,7 +76,6 @@ import {
|
|
|
72
76
|
Client,
|
|
73
77
|
Query,
|
|
74
78
|
} from "@appwrite.io/console";
|
|
75
|
-
import { checkDeployConditions } from "../utils.js";
|
|
76
79
|
import { Pools } from "./utils/pools.js";
|
|
77
80
|
import { Attributes, Collection } from "./utils/attributes.js";
|
|
78
81
|
import {
|
|
@@ -98,6 +101,7 @@ export interface PushOptions {
|
|
|
98
101
|
topics?: boolean;
|
|
99
102
|
skipDeprecated?: boolean;
|
|
100
103
|
skipConfirmation?: boolean;
|
|
104
|
+
force?: boolean;
|
|
101
105
|
functionOptions?: {
|
|
102
106
|
async?: boolean;
|
|
103
107
|
code?: boolean;
|
|
@@ -200,207 +204,219 @@ export class Push {
|
|
|
200
204
|
results: Record<string, any>;
|
|
201
205
|
errors: any[];
|
|
202
206
|
}> {
|
|
203
|
-
const
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
const shouldPushAll = options.all === true;
|
|
207
|
-
|
|
208
|
-
// Push settings
|
|
209
|
-
if (
|
|
210
|
-
(shouldPushAll || options.settings) &&
|
|
211
|
-
(config.projectName || config.settings)
|
|
212
|
-
) {
|
|
213
|
-
try {
|
|
214
|
-
this.log("Pushing settings ...");
|
|
215
|
-
await this.pushSettings({
|
|
216
|
-
projectId: config.projectId,
|
|
217
|
-
projectName: config.projectName,
|
|
218
|
-
settings: config.settings,
|
|
219
|
-
});
|
|
220
|
-
this.success(
|
|
221
|
-
`Successfully pushed ${chalk.bold("all")} project settings.`,
|
|
222
|
-
);
|
|
223
|
-
results.settings = { success: true };
|
|
224
|
-
} catch (e: any) {
|
|
225
|
-
allErrors.push(e);
|
|
226
|
-
results.settings = { success: false, error: e.message };
|
|
227
|
-
}
|
|
207
|
+
const previousForce = cliConfig.force;
|
|
208
|
+
if (options.force !== undefined) {
|
|
209
|
+
cliConfig.force = options.force;
|
|
228
210
|
}
|
|
229
211
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
212
|
+
try {
|
|
213
|
+
const { skipDeprecated = true } = options;
|
|
214
|
+
const results: Record<string, any> = {};
|
|
215
|
+
const allErrors: any[] = [];
|
|
216
|
+
const shouldPushAll = options.all === true;
|
|
217
|
+
|
|
218
|
+
// Push settings
|
|
219
|
+
if (
|
|
220
|
+
(shouldPushAll || options.settings) &&
|
|
221
|
+
(config.projectName || config.settings)
|
|
222
|
+
) {
|
|
223
|
+
try {
|
|
224
|
+
this.log("Pushing settings ...");
|
|
225
|
+
await this.pushSettings({
|
|
226
|
+
projectId: config.projectId,
|
|
227
|
+
projectName: config.projectName,
|
|
228
|
+
settings: config.settings,
|
|
229
|
+
});
|
|
230
|
+
this.success(
|
|
231
|
+
`Successfully pushed ${chalk.bold("all")} project settings.`,
|
|
232
|
+
);
|
|
233
|
+
results.settings = { success: true };
|
|
234
|
+
} catch (e: any) {
|
|
235
|
+
allErrors.push(e);
|
|
236
|
+
results.settings = { success: false, error: e.message };
|
|
237
|
+
}
|
|
247
238
|
}
|
|
248
|
-
}
|
|
249
239
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
240
|
+
// Push buckets
|
|
241
|
+
if (
|
|
242
|
+
(shouldPushAll || options.buckets) &&
|
|
243
|
+
config.buckets &&
|
|
244
|
+
config.buckets.length > 0
|
|
245
|
+
) {
|
|
246
|
+
try {
|
|
247
|
+
this.log("Pushing buckets ...");
|
|
248
|
+
const result = await this.pushBuckets(config.buckets);
|
|
249
|
+
this.success(
|
|
250
|
+
`Successfully pushed ${chalk.bold(result.successfullyPushed)} buckets.`,
|
|
251
|
+
);
|
|
252
|
+
results.buckets = result;
|
|
253
|
+
allErrors.push(...result.errors);
|
|
254
|
+
} catch (e: any) {
|
|
255
|
+
allErrors.push(e);
|
|
256
|
+
results.buckets = { successfullyPushed: 0, errors: [e] };
|
|
257
|
+
}
|
|
267
258
|
}
|
|
268
|
-
}
|
|
269
259
|
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
260
|
+
// Push teams
|
|
261
|
+
if (
|
|
262
|
+
(shouldPushAll || options.teams) &&
|
|
263
|
+
config.teams &&
|
|
264
|
+
config.teams.length > 0
|
|
265
|
+
) {
|
|
266
|
+
try {
|
|
267
|
+
this.log("Pushing teams ...");
|
|
268
|
+
const result = await this.pushTeams(config.teams);
|
|
269
|
+
this.success(
|
|
270
|
+
`Successfully pushed ${chalk.bold(result.successfullyPushed)} teams.`,
|
|
271
|
+
);
|
|
272
|
+
results.teams = result;
|
|
273
|
+
allErrors.push(...result.errors);
|
|
274
|
+
} catch (e: any) {
|
|
275
|
+
allErrors.push(e);
|
|
276
|
+
results.teams = { successfullyPushed: 0, errors: [e] };
|
|
277
|
+
}
|
|
287
278
|
}
|
|
288
|
-
}
|
|
289
279
|
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
)
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
allErrors.push(e);
|
|
309
|
-
results.functions = {
|
|
310
|
-
successfullyPushed: 0,
|
|
311
|
-
successfullyDeployed: 0,
|
|
312
|
-
failedDeployments: [],
|
|
313
|
-
errors: [e],
|
|
314
|
-
};
|
|
280
|
+
// Push messaging topics
|
|
281
|
+
if (
|
|
282
|
+
(shouldPushAll || options.topics) &&
|
|
283
|
+
config.topics &&
|
|
284
|
+
config.topics.length > 0
|
|
285
|
+
) {
|
|
286
|
+
try {
|
|
287
|
+
this.log("Pushing topics ...");
|
|
288
|
+
const result = await this.pushMessagingTopics(config.topics);
|
|
289
|
+
this.success(
|
|
290
|
+
`Successfully pushed ${chalk.bold(result.successfullyPushed)} topics.`,
|
|
291
|
+
);
|
|
292
|
+
results.topics = result;
|
|
293
|
+
allErrors.push(...result.errors);
|
|
294
|
+
} catch (e: any) {
|
|
295
|
+
allErrors.push(e);
|
|
296
|
+
results.topics = { successfullyPushed: 0, errors: [e] };
|
|
297
|
+
}
|
|
315
298
|
}
|
|
316
|
-
}
|
|
317
299
|
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
300
|
+
// Push functions
|
|
301
|
+
if (
|
|
302
|
+
(shouldPushAll || options.functions) &&
|
|
303
|
+
config.functions &&
|
|
304
|
+
config.functions.length > 0
|
|
305
|
+
) {
|
|
306
|
+
try {
|
|
307
|
+
this.log("Pushing functions ...");
|
|
308
|
+
const result = await this.pushFunctions(
|
|
309
|
+
config.functions,
|
|
310
|
+
options.functionOptions,
|
|
311
|
+
);
|
|
312
|
+
this.success(
|
|
313
|
+
`Successfully pushed ${chalk.bold(result.successfullyPushed)} functions.`,
|
|
314
|
+
);
|
|
315
|
+
results.functions = result;
|
|
316
|
+
allErrors.push(...result.errors);
|
|
317
|
+
} catch (e: any) {
|
|
318
|
+
allErrors.push(e);
|
|
319
|
+
results.functions = {
|
|
320
|
+
successfullyPushed: 0,
|
|
321
|
+
successfullyDeployed: 0,
|
|
322
|
+
failedDeployments: [],
|
|
323
|
+
errors: [e],
|
|
324
|
+
};
|
|
325
|
+
}
|
|
340
326
|
}
|
|
341
|
-
}
|
|
342
327
|
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
328
|
+
// Push sites
|
|
329
|
+
if (
|
|
330
|
+
(shouldPushAll || options.sites) &&
|
|
331
|
+
config.sites &&
|
|
332
|
+
config.sites.length > 0
|
|
333
|
+
) {
|
|
334
|
+
try {
|
|
335
|
+
this.log("Pushing sites ...");
|
|
336
|
+
const result = await this.pushSites(
|
|
337
|
+
config.sites,
|
|
338
|
+
options.siteOptions,
|
|
339
|
+
);
|
|
340
|
+
this.success(
|
|
341
|
+
`Successfully pushed ${chalk.bold(result.successfullyPushed)} sites.`,
|
|
342
|
+
);
|
|
343
|
+
results.sites = result;
|
|
344
|
+
allErrors.push(...result.errors);
|
|
345
|
+
} catch (e: any) {
|
|
346
|
+
allErrors.push(e);
|
|
347
|
+
results.sites = {
|
|
348
|
+
successfullyPushed: 0,
|
|
349
|
+
successfullyDeployed: 0,
|
|
350
|
+
failedDeployments: [],
|
|
351
|
+
errors: [e],
|
|
352
|
+
};
|
|
353
|
+
}
|
|
363
354
|
}
|
|
364
|
-
}
|
|
365
355
|
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
)
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
skipConfirmation: options.skipConfirmation,
|
|
388
|
-
});
|
|
389
|
-
this.success(
|
|
390
|
-
`Successfully pushed ${chalk.bold(result.successfullyPushed)} collections.`,
|
|
391
|
-
);
|
|
392
|
-
results.collections = result;
|
|
393
|
-
allErrors.push(...result.errors);
|
|
394
|
-
} catch (e: any) {
|
|
395
|
-
allErrors.push(e);
|
|
396
|
-
results.collections = { successfullyPushed: 0, errors: [e] };
|
|
356
|
+
// Push tables
|
|
357
|
+
if (
|
|
358
|
+
(shouldPushAll || options.tables) &&
|
|
359
|
+
config.tables &&
|
|
360
|
+
config.tables.length > 0
|
|
361
|
+
) {
|
|
362
|
+
try {
|
|
363
|
+
this.log("Pushing tables ...");
|
|
364
|
+
const result = await this.pushTables(config.tables, {
|
|
365
|
+
attempts: options.tableOptions?.attempts,
|
|
366
|
+
skipConfirmation: options.skipConfirmation,
|
|
367
|
+
});
|
|
368
|
+
this.success(
|
|
369
|
+
`Successfully pushed ${chalk.bold(result.successfullyPushed)} tables.`,
|
|
370
|
+
);
|
|
371
|
+
results.tables = result;
|
|
372
|
+
allErrors.push(...result.errors);
|
|
373
|
+
} catch (e: any) {
|
|
374
|
+
allErrors.push(e);
|
|
375
|
+
results.tables = { successfullyPushed: 0, errors: [e] };
|
|
376
|
+
}
|
|
397
377
|
}
|
|
398
|
-
}
|
|
399
378
|
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
379
|
+
// Push collections (skipDeprecated only applies when pushing all, explicit collections option takes precedence)
|
|
380
|
+
if (
|
|
381
|
+
(options.collections || (shouldPushAll && !skipDeprecated)) &&
|
|
382
|
+
config.collections &&
|
|
383
|
+
config.collections.length > 0
|
|
384
|
+
) {
|
|
385
|
+
try {
|
|
386
|
+
this.log("Pushing collections ...");
|
|
387
|
+
// Add database names to collections
|
|
388
|
+
const collectionsWithDbNames = config.collections.map(
|
|
389
|
+
(collection: any) => {
|
|
390
|
+
const database = config.databases?.find(
|
|
391
|
+
(db: any) => db.$id === collection.databaseId,
|
|
392
|
+
);
|
|
393
|
+
return {
|
|
394
|
+
...collection,
|
|
395
|
+
databaseName: database?.name ?? collection.databaseId,
|
|
396
|
+
};
|
|
397
|
+
},
|
|
398
|
+
);
|
|
399
|
+
const result = await this.pushCollections(collectionsWithDbNames, {
|
|
400
|
+
skipConfirmation: options.skipConfirmation,
|
|
401
|
+
});
|
|
402
|
+
this.success(
|
|
403
|
+
`Successfully pushed ${chalk.bold(result.successfullyPushed)} collections.`,
|
|
404
|
+
);
|
|
405
|
+
results.collections = result;
|
|
406
|
+
allErrors.push(...result.errors);
|
|
407
|
+
} catch (e: any) {
|
|
408
|
+
allErrors.push(e);
|
|
409
|
+
results.collections = { successfullyPushed: 0, errors: [e] };
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
return {
|
|
414
|
+
results,
|
|
415
|
+
errors: allErrors,
|
|
416
|
+
};
|
|
417
|
+
} finally {
|
|
418
|
+
cliConfig.force = previousForce;
|
|
419
|
+
}
|
|
404
420
|
}
|
|
405
421
|
|
|
406
422
|
public async pushSettings(config: {
|
|
@@ -489,13 +505,54 @@ export class Push {
|
|
|
489
505
|
let successfullyPushed = 0;
|
|
490
506
|
const errors: any[] = [];
|
|
491
507
|
|
|
508
|
+
const hasBucketChanges = (remoteBucket: any, localBucket: any): boolean => {
|
|
509
|
+
const scalarFields = [
|
|
510
|
+
"name",
|
|
511
|
+
"fileSecurity",
|
|
512
|
+
"enabled",
|
|
513
|
+
"maximumFileSize",
|
|
514
|
+
"encryption",
|
|
515
|
+
"antivirus",
|
|
516
|
+
"compression",
|
|
517
|
+
] as const;
|
|
518
|
+
|
|
519
|
+
if (
|
|
520
|
+
scalarFields.some((field) => remoteBucket[field] !== localBucket[field])
|
|
521
|
+
) {
|
|
522
|
+
return true;
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
if (
|
|
526
|
+
!arrayEqualsUnordered(
|
|
527
|
+
remoteBucket["$permissions"],
|
|
528
|
+
localBucket["$permissions"],
|
|
529
|
+
)
|
|
530
|
+
) {
|
|
531
|
+
return true;
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
return !arrayEqualsUnordered(
|
|
535
|
+
remoteBucket.allowedFileExtensions,
|
|
536
|
+
localBucket.allowedFileExtensions,
|
|
537
|
+
);
|
|
538
|
+
};
|
|
539
|
+
|
|
492
540
|
for (const bucket of buckets) {
|
|
493
541
|
try {
|
|
494
542
|
this.log(`Pushing bucket ${chalk.bold(bucket["name"])} ...`);
|
|
495
543
|
const storageService = await getStorageService(this.projectClient);
|
|
496
544
|
|
|
497
545
|
try {
|
|
498
|
-
await storageService.getBucket(bucket["$id"]);
|
|
546
|
+
const remoteBucket = await storageService.getBucket(bucket["$id"]);
|
|
547
|
+
const hasChanges = hasBucketChanges(remoteBucket, bucket);
|
|
548
|
+
|
|
549
|
+
if (!hasChanges) {
|
|
550
|
+
this.log(
|
|
551
|
+
`No changes detected for bucket ${chalk.bold(bucket["name"])}. Skipping.`,
|
|
552
|
+
);
|
|
553
|
+
continue;
|
|
554
|
+
}
|
|
555
|
+
|
|
499
556
|
await storageService.updateBucket({
|
|
500
557
|
bucketId: bucket["$id"],
|
|
501
558
|
name: bucket.name,
|
|
@@ -508,6 +565,7 @@ export class Push {
|
|
|
508
565
|
antivirus: bucket.antivirus,
|
|
509
566
|
compression: bucket.compression,
|
|
510
567
|
});
|
|
568
|
+
successfullyPushed++;
|
|
511
569
|
} catch (e: unknown) {
|
|
512
570
|
if (e instanceof AppwriteException && Number(e.code) === 404) {
|
|
513
571
|
await storageService.createBucket({
|
|
@@ -522,12 +580,11 @@ export class Push {
|
|
|
522
580
|
encryption: bucket.encryption,
|
|
523
581
|
antivirus: bucket.antivirus,
|
|
524
582
|
});
|
|
583
|
+
successfullyPushed++;
|
|
525
584
|
} else {
|
|
526
585
|
throw e;
|
|
527
586
|
}
|
|
528
587
|
}
|
|
529
|
-
|
|
530
|
-
successfullyPushed++;
|
|
531
588
|
} catch (e: any) {
|
|
532
589
|
errors.push(e);
|
|
533
590
|
this.error(`Failed to push bucket ${bucket["name"]}: ${e.message}`);
|
|
@@ -1360,8 +1417,12 @@ export class Push {
|
|
|
1360
1417
|
}> {
|
|
1361
1418
|
const { attempts, skipConfirmation = false } = options;
|
|
1362
1419
|
const pollMaxDebounces = attempts ?? POLL_DEFAULT_VALUE;
|
|
1363
|
-
const pools = new Pools(pollMaxDebounces);
|
|
1364
|
-
const attributes = new Attributes(
|
|
1420
|
+
const pools = new Pools(pollMaxDebounces, this.projectClient);
|
|
1421
|
+
const attributes = new Attributes(
|
|
1422
|
+
pools,
|
|
1423
|
+
skipConfirmation,
|
|
1424
|
+
this.projectClient,
|
|
1425
|
+
);
|
|
1365
1426
|
|
|
1366
1427
|
let tablesChanged = new Set();
|
|
1367
1428
|
const errors: any[] = [];
|
|
@@ -1454,6 +1515,11 @@ export class Push {
|
|
|
1454
1515
|
hadChanges = columnsResult.hasChanges || indexesResult.hasChanges;
|
|
1455
1516
|
|
|
1456
1517
|
if (!hadChanges && columns.length <= 0 && indexes.length <= 0) {
|
|
1518
|
+
if (!tablesChanged.has(table["$id"])) {
|
|
1519
|
+
this.log(
|
|
1520
|
+
`No changes detected for table ${chalk.bold(table["name"])}. Skipping.`,
|
|
1521
|
+
);
|
|
1522
|
+
}
|
|
1457
1523
|
continue;
|
|
1458
1524
|
}
|
|
1459
1525
|
}
|
|
@@ -1493,8 +1559,12 @@ export class Push {
|
|
|
1493
1559
|
errors: Error[];
|
|
1494
1560
|
}> {
|
|
1495
1561
|
const { skipConfirmation = false } = options;
|
|
1496
|
-
const pools = new Pools(POLL_DEFAULT_VALUE);
|
|
1497
|
-
const attributesHelper = new Attributes(
|
|
1562
|
+
const pools = new Pools(POLL_DEFAULT_VALUE, this.projectClient);
|
|
1563
|
+
const attributesHelper = new Attributes(
|
|
1564
|
+
pools,
|
|
1565
|
+
skipConfirmation,
|
|
1566
|
+
this.projectClient,
|
|
1567
|
+
);
|
|
1498
1568
|
|
|
1499
1569
|
const errors: Error[] = [];
|
|
1500
1570
|
|
|
@@ -1933,7 +2003,20 @@ const pushSite = async ({
|
|
|
1933
2003
|
|
|
1934
2004
|
failedDeployments.forEach((failed) => {
|
|
1935
2005
|
const { name, deployment, $id } = failed;
|
|
1936
|
-
const
|
|
2006
|
+
const projectId = localConfig.getProject().projectId;
|
|
2007
|
+
const endpoint = localConfig.getEndpoint() || globalConfig.getEndpoint();
|
|
2008
|
+
let region = "";
|
|
2009
|
+
try {
|
|
2010
|
+
const hostname = new URL(endpoint).hostname;
|
|
2011
|
+
const firstSubdomain = hostname.split(".")[0];
|
|
2012
|
+
if (firstSubdomain.length === 3) {
|
|
2013
|
+
region = firstSubdomain;
|
|
2014
|
+
}
|
|
2015
|
+
} catch {}
|
|
2016
|
+
const projectSlug = region
|
|
2017
|
+
? `project-${region}-${projectId}`
|
|
2018
|
+
: `project-${projectId}`;
|
|
2019
|
+
const failUrl = `${globalConfig.getEndpoint().slice(0, -3)}/console/${projectSlug}/sites/site-${$id}/deployments/deployment-${deployment}`;
|
|
1937
2020
|
|
|
1938
2021
|
error(
|
|
1939
2022
|
`Deployment of ${name} has failed. Check at ${failUrl} for more details\n`,
|
|
@@ -2061,7 +2144,20 @@ const pushFunction = async ({
|
|
|
2061
2144
|
|
|
2062
2145
|
failedDeployments.forEach((failed) => {
|
|
2063
2146
|
const { name, deployment, $id } = failed;
|
|
2064
|
-
const
|
|
2147
|
+
const projectId = localConfig.getProject().projectId;
|
|
2148
|
+
const endpoint = localConfig.getEndpoint() || globalConfig.getEndpoint();
|
|
2149
|
+
let region = "";
|
|
2150
|
+
try {
|
|
2151
|
+
const hostname = new URL(endpoint).hostname;
|
|
2152
|
+
const firstSubdomain = hostname.split(".")[0];
|
|
2153
|
+
if (firstSubdomain.length === 3) {
|
|
2154
|
+
region = firstSubdomain;
|
|
2155
|
+
}
|
|
2156
|
+
} catch {}
|
|
2157
|
+
const projectSlug = region
|
|
2158
|
+
? `project-${region}-${projectId}`
|
|
2159
|
+
: `project-${projectId}`;
|
|
2160
|
+
const failUrl = `${globalConfig.getEndpoint().slice(0, -3)}/console/${projectSlug}/functions/function-${$id}/deployment-${deployment}`;
|
|
2065
2161
|
|
|
2066
2162
|
error(
|
|
2067
2163
|
`Deployment of ${name} has failed. Check at ${failUrl} for more details\n`,
|
|
@@ -2294,12 +2390,13 @@ const pushCollection = async (): Promise<void> => {
|
|
|
2294
2390
|
const localDatabase = localConfig.getDatabase(collection.databaseId);
|
|
2295
2391
|
collection.databaseName = localDatabase.name ?? collection.databaseId;
|
|
2296
2392
|
});
|
|
2393
|
+
const projectClient = await sdkForProject();
|
|
2297
2394
|
|
|
2298
2395
|
if (
|
|
2299
2396
|
!(await approveChanges(
|
|
2300
2397
|
collections,
|
|
2301
2398
|
async (args: any) => {
|
|
2302
|
-
const databasesService = await getDatabasesService();
|
|
2399
|
+
const databasesService = await getDatabasesService(projectClient);
|
|
2303
2400
|
return await databasesService.getCollection(
|
|
2304
2401
|
args.databaseId,
|
|
2305
2402
|
args.collectionId,
|