19
19
from . import crypto
20
20
except ImportError :
21
21
crypto = None
22
- from .localdev .utils import get_aldryn_project_settings
22
+ from .localdev .utils import allow_remote_id_override
23
23
from .cloud import CloudClient , get_endpoint
24
24
from .check_system import check_requirements , check_requirements_human
25
25
from .utils import (
26
26
hr , table , open_project_cloud_site ,
27
27
get_cp_url , get_git_checked_branch ,
28
- print_package_renamed_warning ,
29
- Map , check_project_context ,
28
+ print_package_renamed_warning , Map ,
30
29
)
31
30
from .validators .addon import validate_addon
32
31
from .validators .boilerplate import validate_boilerplate
@@ -107,25 +106,9 @@ def login(ctx, token, check):
107
106
108
107
109
108
@cli .group ()
110
- @click .option (
111
- '--id' , 'identifier' ,
112
- default = None , type = int ,
113
- help = 'Project.id to use for project commands. '
114
- 'Defaults to the project in the current directory using the .aldryn '
115
- 'file.'
116
- )
117
- @click .pass_obj
118
- def project (obj , identifier ):
109
+ def project ():
119
110
"""Manage your projects"""
120
- if identifier :
121
- obj .project = {
122
- 'id' : identifier ,
123
- }
124
- else :
125
- try :
126
- obj .project = get_aldryn_project_settings (silent = True )
127
- except Exception as exc :
128
- obj .project = {}
111
+ pass
129
112
130
113
131
114
@project .command (name = 'list' )
@@ -211,49 +194,44 @@ def sort_projects(items):
211
194
help = 'Take a backup on deployment.' ,
212
195
)
213
196
@click .argument ('stage' , default = 'test' )
197
+ @allow_remote_id_override
214
198
@click .pass_obj
215
- def project_deploy (obj , stage , backup ):
199
+ def project_deploy (obj , remote_id , stage , backup ):
216
200
"""Deploy project"""
217
- check_project_context (obj .project )
218
- website_id = obj .project ['id' ]
219
- obj .client .deploy_project_or_get_progress (website_id , stage , backup )
201
+ obj .client .deploy_project_or_get_progress (remote_id , stage , backup )
220
202
221
203
222
204
@project .command (name = 'deploy-log' )
223
205
@click .argument ('stage' , default = 'test' )
206
+ @allow_remote_id_override
224
207
@click .pass_obj
225
- def project_deploy_log (obj , stage ):
208
+ def project_deploy_log (obj , remote_id , stage ):
226
209
"""View last deployment log"""
227
- check_project_context (obj .project )
228
- website_id = obj .project ['id' ]
229
- obj .client .show_deploy_log (website_id , stage )
210
+ obj .client .show_deploy_log (remote_id , stage )
230
211
231
212
232
213
@project .command (name = 'dashboard' )
214
+ @allow_remote_id_override
233
215
@click .pass_obj
234
- def project_dashboard (obj ):
216
+ def project_dashboard (obj , remote_id ):
235
217
"""Open project dashboard"""
236
- check_project_context (obj .project )
237
- click .launch (get_cp_url (obj .client , obj .project ))
218
+ click .launch (get_cp_url (obj .client , remote_id ))
238
219
239
220
240
221
@project .command (name = 'up' )
241
- @click .pass_obj
242
- def project_up (obj ):
222
+ def project_up ():
243
223
"""Start local project"""
244
224
localdev .start_project ()
245
225
246
226
247
227
@project .command (name = 'open' )
248
- @click .pass_obj
249
- def project_open (obj ):
228
+ def project_open ():
250
229
"""Open local project in browser"""
251
230
localdev .open_project ()
252
231
253
232
254
233
@project .command (name = 'update' )
255
- @click .pass_obj
256
- def project_update (obj ):
234
+ def project_update ():
257
235
"""Update project with latest changes from the Cloud"""
258
236
localdev .update_local_project (get_git_checked_branch ())
259
237
@@ -288,32 +266,36 @@ def project_update(obj):
288
266
multiple = True ,
289
267
help = 'unset an environment variable' ,
290
268
)
269
+ @allow_remote_id_override
291
270
@click .pass_obj
292
- def environment_variables (
293
- obj , stage , show_all_vars , as_json , get_vars , set_vars , unset_vars
294
- ):
271
+ def environment_variables (obj , remote_id , stage , show_all_vars ,
272
+ as_json , get_vars , set_vars , unset_vars ):
295
273
"""
296
274
Get and set environment vars.
297
275
298
276
WARNING: This command is experimental and may change in a future release.
299
277
"""
300
- check_project_context (obj .project )
301
278
if set_vars or unset_vars :
302
279
set_vars = dict (set_vars )
303
280
data = obj .client .set_custom_environment_variables (
304
- website_id = obj . project [ 'id' ] ,
281
+ website_id = remote_id ,
305
282
stage = stage ,
306
283
set_vars = set_vars ,
307
284
unset_vars = unset_vars ,
308
285
)
309
286
else :
310
287
data = obj .client .get_environment_variables (
311
- website_id = obj . project [ 'id' ] ,
288
+ website_id = remote_id ,
312
289
stage = stage ,
313
290
custom_only = not show_all_vars ,
314
291
)
315
292
if get_vars :
316
- data = {key : value for key , value in data .items () if key in get_vars }
293
+ data = {
294
+ key : value
295
+ for key , value
296
+ in data .items ()
297
+ if key in get_vars
298
+ }
317
299
if as_json :
318
300
click .echo (json .dumps (data , indent = 2 , sort_keys = True ))
319
301
else :
@@ -324,41 +306,39 @@ def environment_variables(
324
306
325
307
326
308
@project .command (name = 'test' )
309
+ @allow_remote_id_override
327
310
@click .pass_obj
328
- def project_open_test (obj ):
311
+ def project_open_test (obj , remote_id ):
329
312
"""Open project test site"""
330
- check_project_context (obj .project )
331
- open_project_cloud_site (obj .client , obj .project , 'test' )
313
+ open_project_cloud_site (obj .client , remote_id , 'test' )
332
314
333
315
334
316
@project .command (name = 'live' )
317
+ @allow_remote_id_override
335
318
@click .pass_obj
336
- def project_open_live (obj ):
319
+ def project_open_live (obj , remote_id ):
337
320
"""Open project live site"""
338
- check_project_context (obj .project )
339
- open_project_cloud_site (obj .client , obj .project , 'live' )
321
+ open_project_cloud_site (obj .client , remote_id , 'live' )
340
322
341
323
342
324
@project .command (name = 'status' )
343
- @click .pass_obj
344
- def project_status (obj ):
325
+ def project_status ():
345
326
"""Show local project status"""
346
327
localdev .show_project_status ()
347
328
348
329
349
330
@project .command (name = 'stop' )
350
- @click .pass_obj
351
- def project_stop (obj ):
331
+ def project_stop ():
352
332
"""Stop local project"""
353
333
localdev .stop_project ()
354
334
355
335
356
336
@project .command (name = 'cheatsheet' )
337
+ @allow_remote_id_override
357
338
@click .pass_obj
358
- def project_cheatsheet (obj ):
339
+ def project_cheatsheet (obj , remote_id ):
359
340
"""Show useful commands for your project"""
360
- check_project_context (obj .project )
361
- click .launch (get_cp_url (obj .client , obj .project , 'local-development/' ))
341
+ click .launch (get_cp_url (obj .client , remote_id , 'local-development/' ))
362
342
363
343
364
344
@project .command (name = 'setup' )
@@ -402,24 +382,28 @@ def project_pull():
402
382
403
383
@project_pull .command (name = 'db' )
404
384
@click .argument ('stage' , default = 'test' )
385
+ @allow_remote_id_override
405
386
@click .pass_obj
406
- def pull_db (obj , stage ):
387
+ def pull_db (obj , remote_id , stage ):
407
388
"""
408
389
Pull database from your deployed website. Stage is either
409
390
test (default) or live
410
391
"""
411
- localdev .ImportRemoteDatabase (client = obj .client , stage = stage )()
392
+ localdev .ImportRemoteDatabase (
393
+ client = obj .client , stage = stage , remote_id = remote_id ,
394
+ )()
412
395
413
396
414
397
@project_pull .command (name = 'media' )
415
398
@click .argument ('stage' , default = 'test' )
399
+ @allow_remote_id_override
416
400
@click .pass_obj
417
- def pull_media (obj , stage ):
401
+ def pull_media (obj , remote_id , stage ):
418
402
"""
419
403
Pull media files from your deployed website. Stage is either
420
404
test (default) or live
421
405
"""
422
- localdev .pull_media (obj .client , stage )
406
+ localdev .pull_media (obj .client , stage , remote_id )
423
407
424
408
425
409
@project .group (name = 'push' )
@@ -436,8 +420,9 @@ def project_push():
436
420
@click .option (
437
421
'--noinput' , is_flag = True , default = False ,
438
422
help = "Don't ask for confirmation" )
423
+ @allow_remote_id_override
439
424
@click .pass_obj
440
- def push_db (obj , stage , dumpfile , noinput ):
425
+ def push_db (obj , remote_id , stage , dumpfile , noinput ):
441
426
"""
442
427
Push database to your deployed website. Stage is either
443
428
test (default) or live
@@ -447,24 +432,21 @@ def push_db(obj, stage, dumpfile, noinput):
447
432
click .secho (messages .PUSH_DB_WARNING .format (stage = stage ), fg = 'red' )
448
433
if not click .confirm ('\n Are you sure you want to continue?' ):
449
434
return
450
- localdev .push_db (obj .client , stage )
435
+ localdev .push_db (obj .client , stage , remote_id )
451
436
else :
452
- if not obj .project .has_key ('id' ):
453
- click .secho ('\n This only works with project_id, please enter project_id using --id' , fg = 'red' )
454
- else :
455
- website_id = obj .project ['id' ]
456
- if not noinput :
457
- click .secho (messages .PUSH_DB_WARNING .format (stage = stage ), fg = 'red' )
458
- if not click .confirm ('\n Are you sure you want to continue?' ):
459
- return
460
- localdev .push_local_db (obj .client , stage , dumpfile , website_id )
437
+ if not noinput :
438
+ click .secho (messages .PUSH_DB_WARNING .format (stage = stage ), fg = 'red' )
439
+ if not click .confirm ('\n Are you sure you want to continue?' ):
440
+ return
441
+ localdev .push_local_db (obj .client , stage , dumpfile , remote_id )
461
442
462
443
463
444
@project_push .command (name = 'media' )
464
445
@click .argument ('stage' , default = 'test' )
465
446
@click .option ('--noinput' , is_flag = True , default = False , help = "Don't ask for confirmation" )
447
+ @allow_remote_id_override
466
448
@click .pass_obj
467
- def push_media (obj , stage , noinput ):
449
+ def push_media (obj , remote_id , stage , noinput ):
468
450
"""
469
451
Push database to your deployed website. Stage is either
470
452
test (default) or live
@@ -474,7 +456,7 @@ def push_media(obj, stage, noinput):
474
456
click .secho (messages .PUSH_MEDIA_WARNING .format (stage = stage ), fg = 'red' )
475
457
if not click .confirm ('\n Are you sure you want to continue?' ):
476
458
return
477
- localdev .push_media (obj .client , stage )
459
+ localdev .push_media (obj .client , stage , remote_id )
478
460
479
461
480
462
@project .group (name = 'import' )
@@ -513,8 +495,7 @@ def export_db():
513
495
'--no-rebuild' , is_flag = True , default = False ,
514
496
help = 'Do not rebuild docker container automatically'
515
497
)
516
- @click .pass_obj
517
- def project_develop (obj , package , no_rebuild ):
498
+ def project_develop (package , no_rebuild ):
518
499
"""Add a package 'package' to your local project environment"""
519
500
localdev .develop_package (package , no_rebuild )
520
501
0 commit comments