zrb 0.0.50__py3-none-any.whl → 0.0.52__py3-none-any.whl

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.
Files changed (63) hide show
  1. zrb/action/runner.py +15 -3
  2. zrb/builtin/generator/docker_compose_task/template/_automate/snake_task_name.py +1 -1
  3. zrb/builtin/generator/fastapp/add.py +3 -2
  4. zrb/builtin/generator/fastapp/template/_automate/snake_app_name/frontend.py +17 -2
  5. zrb/builtin/generator/fastapp/template/src/kebab-app-name/src/.gitignore +2 -1
  6. zrb/builtin/generator/fastapp/template/src/kebab-app-name/src/Dockerfile +1 -1
  7. zrb/builtin/generator/fastapp/template/src/kebab-app-name/src/config.py +3 -0
  8. zrb/builtin/generator/fastapp/template/src/kebab-app-name/src/core/messagebus/rabbitmq/consumer.py +4 -1
  9. zrb/builtin/generator/fastapp/template/src/kebab-app-name/src/frontend/.gitignore +2 -2
  10. zrb/builtin/generator/fastapp/template/src/kebab-app-name/src/frontend/package-lock.json +197 -115
  11. zrb/builtin/generator/fastapp/template/src/kebab-app-name/src/frontend/package.json +7 -1
  12. zrb/builtin/generator/fastapp/template/src/kebab-app-name/src/frontend/src/app.html +1 -1
  13. zrb/builtin/generator/fastapp/template/src/kebab-app-name/src/frontend/src/lib/auth/auth.ts +83 -0
  14. zrb/builtin/generator/fastapp/template/src/kebab-app-name/src/frontend/src/lib/auth/store.ts +4 -0
  15. zrb/builtin/generator/fastapp/template/src/kebab-app-name/src/frontend/src/lib/auth/type.ts +10 -0
  16. zrb/builtin/generator/fastapp/template/src/kebab-app-name/src/frontend/src/lib/components/navigation/Menu.svelte +20 -0
  17. zrb/builtin/generator/fastapp/template/src/kebab-app-name/src/frontend/src/lib/components/navigation/Navigation.svelte +77 -0
  18. zrb/builtin/generator/fastapp/template/src/kebab-app-name/src/frontend/src/lib/components/navigation/type.ts +6 -0
  19. zrb/builtin/generator/fastapp/template/src/kebab-app-name/src/frontend/src/lib/config/config.ts +4 -0
  20. zrb/builtin/generator/fastapp/template/src/kebab-app-name/src/frontend/src/lib/config/navData.ts +25 -0
  21. zrb/builtin/generator/fastapp/template/src/kebab-app-name/src/frontend/src/lib/cookie/cookie.ts +19 -0
  22. zrb/builtin/generator/fastapp/template/src/kebab-app-name/src/frontend/src/routes/+layout.svelte +9 -6
  23. zrb/builtin/generator/fastapp/template/src/kebab-app-name/src/frontend/src/routes/greetings/[slug]/+page.js +4 -4
  24. zrb/builtin/generator/fastapp/template/src/kebab-app-name/src/frontend/src/routes/greetings/[slug]/+page.svelte +3 -7
  25. zrb/builtin/generator/fastapp/template/src/kebab-app-name/src/frontend/src/routes/sample/+page.svelte +37 -0
  26. zrb/builtin/generator/fastapp/template/src/kebab-app-name/src/frontend/src/routes/sample/delete/[id]/+page.svelte +1 -0
  27. zrb/builtin/generator/fastapp/template/src/kebab-app-name/src/frontend/static/favicon.png +0 -0
  28. zrb/builtin/generator/fastapp/template/src/kebab-app-name/src/frontend/static/logo.png +0 -0
  29. zrb/builtin/generator/fastapp/template/src/kebab-app-name/src/frontend/tailwind.config.js +1 -1
  30. zrb/builtin/generator/fastapp/template/src/kebab-app-name/src/module/auth/api.py +1 -1
  31. zrb/builtin/generator/fastapp/template/src/kebab-app-name/src/module/auth/component/authorizer.py +1 -1
  32. zrb/builtin/generator/fastapp/template/src/kebab-app-name/src/module/auth/component/token_scheme.py +1 -1
  33. zrb/builtin/generator/fastapp/template/src/kebab-app-name/src/module/auth/core/authorizer/authorizer.py +1 -1
  34. zrb/builtin/generator/fastapp/template/src/kebab-app-name/src/module/auth/core/authorizer/rpc_authorizer.py +9 -5
  35. zrb/builtin/generator/fastapp/template/src/kebab-app-name/src/module/auth/core/token_scheme/oauth2_bearer_token_scheme.py +1 -1
  36. zrb/builtin/generator/fastapp/template/src/kebab-app-name/src/module/auth/entity/user/api.py +32 -8
  37. zrb/builtin/generator/fastapp/template/src/kebab-app-name/src/module/auth/entity/user/model.py +60 -52
  38. zrb/builtin/generator/fastapp/template/src/kebab-app-name/src/module/auth/entity/user/rpc.py +23 -8
  39. zrb/builtin/generator/fastapp/template/src/kebab-app-name/src/module/auth/schema/request.py +10 -0
  40. zrb/builtin/generator/fastapp/template/src/kebab-app-name/src/template.env +4 -0
  41. zrb/builtin/generator/fastapp/template/src/kebab-app-name/test/auth/test_group_crud.py +3 -3
  42. zrb/builtin/generator/fastapp/template/src/kebab-app-name/test/auth/test_permission_crud.py +3 -3
  43. zrb/builtin/generator/fastapp/template/src/kebab-app-name/test/auth/test_user_crud.py +3 -3
  44. zrb/builtin/generator/fastapp/template/src/kebab-app-name/test/auth/test_user_login.py +12 -12
  45. zrb/builtin/generator/fastapp_crud/add.py +86 -5
  46. zrb/builtin/generator/fastapp_crud/nodejs/codemod/.gitignore +1 -0
  47. zrb/builtin/generator/fastapp_crud/nodejs/codemod/package-lock.json +317 -0
  48. zrb/builtin/generator/fastapp_crud/nodejs/codemod/package.json +18 -0
  49. zrb/builtin/generator/fastapp_crud/nodejs/codemod/src/addNav.ts +38 -0
  50. zrb/builtin/generator/fastapp_crud/nodejs/codemod/tsconfig.json +109 -0
  51. zrb/builtin/generator/fastapp_crud/template/src/kebab-app-name/test/snake_module_name/test_snake_entity_name.py +3 -3
  52. zrb/builtin/generator/project/template/.gitignore +1 -1
  53. zrb/builtin/generator/simple_python_app/template/src/kebab-app-name/src/.gitignore +1 -1
  54. zrb/task/base_task.py +3 -1
  55. zrb-0.0.52.dist-info/METADATA +605 -0
  56. {zrb-0.0.50.dist-info → zrb-0.0.52.dist-info}/RECORD +60 -44
  57. zrb/builtin/generator/fastapp/template/src/kebab-app-name/src/frontend/src/lib/components/Navigation.svelte +0 -24
  58. zrb/builtin/generator/fastapp/template/src/kebab-app-name/src/frontend/src/lib/data/navData.json +0 -5
  59. zrb-0.0.50.dist-info/METADATA +0 -450
  60. /zrb/builtin/generator/{fastapp/template/src/kebab-app-name/src/frontend/src/routes/greetings/[slug]/page.js → fastapp_crud/nodejs/codemod/src/fastapp/src/frontend/src/lib/config/navData.ts} +0 -0
  61. {zrb-0.0.50.dist-info → zrb-0.0.52.dist-info}/LICENSE +0 -0
  62. {zrb-0.0.50.dist-info → zrb-0.0.52.dist-info}/WHEEL +0 -0
  63. {zrb-0.0.50.dist-info → zrb-0.0.52.dist-info}/entry_points.txt +0 -0
@@ -1,450 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: zrb
3
- Version: 0.0.50
4
- Summary: Your faithful companion
5
- Author-email: Go Frendi Gunawan <gofrendiasgard@gmail.com>
6
- Requires-Python: >=3.8
7
- Description-Content-Type: text/markdown
8
- Classifier: Programming Language :: Python :: 3
9
- Classifier: License :: OSI Approved :: MIT License
10
- Classifier: Operating System :: OS Independent
11
- Requires-Dist: click==8.1.3
12
- Requires-Dist: aiofiles==23.1.0
13
- Requires-Dist: typeguard==2.13.3
14
- Requires-Dist: termcolor==2.2.0
15
- Requires-Dist: Jinja2==3.1.2
16
- Requires-Dist: libcst==0.4.9
17
- Requires-Dist: python-dotenv==0.21.1
18
- Requires-Dist: jsons==1.6.3
19
- Requires-Dist: ruamel.yaml==0.17.21
20
- Requires-Dist: setuptools==49.2.1
21
- Requires-Dist: autopep8==2.0.1
22
- Requires-Dist: flake8==6.0.0 ; extra == "dev"
23
- Requires-Dist: pytest==7.2.1 ; extra == "test"
24
- Requires-Dist: pytest-cov==4.0.0 ; extra == "test"
25
- Requires-Dist: pytest-xdist==3.2.0 ; extra == "test"
26
- Requires-Dist: pytest-asyncio==0.21.0 ; extra == "test"
27
- Project-URL: Bug Tracker, https://github.com/state-alchemists/zaruba/issues
28
- Project-URL: Homepage, https://github.com/state-alchemists/zaruba
29
- Provides-Extra: dev
30
- Provides-Extra: test
31
-
32
- # Zrb (WIP)
33
-
34
- Your faithful companion.
35
-
36
- # How to install
37
-
38
- ```bash
39
- pip install zrb
40
- ```
41
-
42
- # How to use
43
-
44
- To run a task, you can invoke the following command:
45
-
46
- ```bash
47
- zrb <task> [arguments]
48
- ```
49
-
50
- # How to create and deploy an app
51
-
52
- ```bash
53
- # Create a project
54
- zrb project create --project-dir my-project --project-name "My Project"
55
- cd my-project
56
-
57
- # Add a simple python app
58
- zrb project add simple-python-app --project-dir . --app-name simple --http-port 3000
59
-
60
- # Start every app in your project
61
- zrb project start
62
-
63
- # or start a specific app (press ctrl+c first):
64
- zrb project start-simple
65
-
66
- # Open new terminal
67
- # test if everything works:
68
- curl http://localhost:3000
69
- # Press ctrl + c in your first terminal
70
-
71
- # Go back to your first terminal
72
- # Start every app in your project as container (docker-compose required)
73
- zrb project start-containers
74
-
75
- # or start a specific app (press ctrl+c first):
76
- zrb project start-simple-container
77
- # Press ctrl + c in your first terminal
78
-
79
- # Deploy to kubernetes
80
- zrb project deploy
81
-
82
- # or deploy specific app
83
- zrb project deploy-simple
84
-
85
- # Remove the deployment
86
- zrb project destroy
87
- ```
88
-
89
- Simple-python-app is a simple Uvicorn application.
90
-
91
- For the next iterations, Zrb will also introduce a serious framework for serious software development.
92
- Stay tunes.
93
-
94
- # Autoloaded tasks
95
-
96
- Zrb will automatically load the following task definitions:
97
-
98
- - Every task definition in `ZRB_INIT_SCRIPTS`.
99
- - You can use a colon separator (`:`) to define multiple scripts in `ZRB_INIT_SCRIPTS`. For example:
100
- ```bash
101
- ZRB_INIT_SCRIPTS=~/personal/zrb_init.py:~/work/zrb_init.py
102
- ```
103
- - Every task definition in `zrb_init.py` in your current directory.
104
- - If Zrb cannot find any in your current directory, it will look at the parent directories until it finds one.
105
- - Every built-in task definition given `ZRB_SHOULD_LOAD_BUILTIN` equals `1` or unset.
106
-
107
- # How to define tasks
108
-
109
- You can write your task definitions in Python. For example:
110
-
111
- ```python
112
- from zrb import (
113
- runner, Env,
114
- StrInput, ChoiceInput, IntInput, BoolInput, FloatInput, PasswordInput,
115
- Group, Task, CmdTask, HTTPChecker, python_task
116
- )
117
-
118
- # Simple Python task.
119
- # Usage example: zrb concat --separator=' '
120
- concat = Task(
121
- name='concat', # Task name
122
- inputs=[StrInput(name='separator', description='Separator', default=' ')],
123
- run=lambda *args, **kwargs: kwargs.get('separator', ' ').join(args)
124
- )
125
- runner.register(concat)
126
-
127
- # Simple Python task with multiple inputs.
128
- register_trainer = Task(
129
- name='register-trainer',
130
- inputs=[
131
- StrInput(name='name', default=''),
132
- PasswordInput(name='password', default=''),
133
- IntInput(name='age', default=0),
134
- BoolInput(name='employed', default=False),
135
- FloatInput(name='salary', default=0.0),
136
- ChoiceInput(
137
- name='starter-pokemon',
138
- choices=['bulbasaur', 'charmender', 'squirtle']
139
- )
140
- ],
141
- run=lambda *args, **kwargs: kwargs
142
- )
143
- runner.register(register_trainer)
144
-
145
-
146
- # Simple Python task with decorator
147
- @python_task(
148
- name='fibo',
149
- inputs=[IntInput(name='n', default=5)],
150
- runner=runner
151
- )
152
- async def fibo(*args, **kwargs):
153
- n = int(args[0]) if len(args) > 0 else kwargs.get('n')
154
- if n <= 0:
155
- return None
156
- elif n == 1:
157
- return 0
158
- elif n == 2:
159
- return 1
160
- else:
161
- a, b = 0, 1
162
- for i in range(n - 1):
163
- a, b = b, a + b
164
- return a
165
-
166
-
167
- # Simple CLI task.
168
- # Usage example: zrb hello --name='world'
169
- hello = CmdTask(
170
- name='hello',
171
- inputs=[StrInput(name='name', description='Name', default='world')],
172
- cmd='echo Hello {{input.name}}'
173
- )
174
- runner.register(hello)
175
-
176
- # Command group: zrb make
177
- make = Group(name='make', description='Make things')
178
-
179
- # CLI task, part of `zrb make` group, depends on `hello`
180
- # Usage example: zrb make coffee
181
- make_coffee = CmdTask(
182
- name='coffee',
183
- group=make,
184
- upstreams=[hello],
185
- cmd='echo Coffee for you ☕'
186
- )
187
- runner.register(make_coffee)
188
-
189
- # CLI task, part of `zrb make` group, depends on `hello`
190
- # Usage example: zrb make beer
191
- make_beer = CmdTask(
192
- name='beer',
193
- group=make,
194
- upstreams=[hello],
195
- cmd='echo Cheers 🍺'
196
- )
197
- runner.register(make_beer)
198
-
199
- # Command group: zrb make gitignore
200
- make_gitignore = Group(
201
- name='gitignore', description='Make gitignore', parent=make
202
- )
203
-
204
- # CLI task, part of `zrb make gitignore` group,
205
- # making .gitignore for Python project
206
- # Usage example: zrb make gitignore python
207
- make_gitignore_python = CmdTask(
208
- name='python',
209
- group=make_gitignore,
210
- cmd=[
211
- 'echo "node_modules/" >> .gitignore'
212
- 'echo ".npm" >> .gitignore'
213
- 'echo "npm-debug.log" >> .gitignore'
214
- ]
215
- )
216
- runner.register(make_gitignore_python)
217
-
218
- # CLI task, part of `zrb make gitignore` group,
219
- # making .gitignore for Node.js project
220
- # Usage example: zrb make gitignore node
221
- make_gitignore_nodejs = CmdTask(
222
- name='node',
223
- group=make_gitignore,
224
- cmd=[
225
- 'echo "__pycache__/" >> .gitignore'
226
- 'echo "venv" >> .gitignore'
227
- ]
228
- )
229
- runner.register(make_gitignore_nodejs)
230
-
231
- # Long running CLI task
232
- # Usage example: zrb start-server dir='.'
233
- start_server = CmdTask(
234
- name='start-server',
235
- upstreams=[make_coffee, make_beer],
236
- inputs=[StrInput(name='dir', description='Directory', default='.')],
237
- envs=[Env(name='PORT', os_name='WEB_PORT', default='3000')],
238
- cmd='python -m http.server $PORT --directory {{input.dir}}',
239
- checkers=[HTTPChecker(port='{{env.PORT}}')]
240
- )
241
- runner.register(start_server)
242
-
243
- # CLI task, depends on `start-server`, throw error
244
- # Usage example: zrb test-error
245
- test_error = CmdTask(
246
- name='test-error',
247
- upstreams=[start_server],
248
- cmd='sleep 3 && exit 1',
249
- retry=0
250
- )
251
- runner.register(test_error)
252
- ```
253
-
254
- Once registered, your task will be accessible from the terminal.
255
-
256
- For example, you can run a server by performing:
257
-
258
- ```bash
259
- export WEB_PORT=8080
260
- zrb start-server
261
- ```
262
-
263
- The output will be similar to this:
264
-
265
- ```
266
- Name [world]: Go Frendi
267
- Dir [.]:
268
- 🤖 ➜ 2023-02-22T08:02:52.611040 ⚙ 14426 ➤ 1 of 3 • 🍋 zrb hello • Hello Go Frendi
269
- 🤖 ➜ 2023-02-22T08:02:52.719826 ⚙ 14428 ➤ 1 of 3 • 🍊 zrb make coffee • Coffee for you ☕
270
- 🤖 ➜ 2023-02-22T08:02:52.720372 ⚙ 14430 ➤ 1 of 3 • 🍒 zrb make beer • Cheers 🍺
271
- 🤖 ➜ 2023-02-22T08:02:52.845930 ⚙ 14432 ➤ 1 of 3 • 🍎 zrb start-server • Serving HTTP on 0.0.0.0 port 3000 (http://0.0.0.0:3000/) ...
272
- 🤖 ➜ 2023-02-22T08:02:52.910192 ⚙ 14425 ➤ 1 of 1 • 🍈 http-check • HEAD http://localhost:3000/ 200 (OK)
273
- Support zrb growth and development!
274
- ☕ Donate at: https://stalchmst.com/donation
275
- 🐙 Submit issues/pull requests at: https://github.com/state-alchemists/zaruba
276
- 🐤 Follow us at: https://twitter.com/zarubastalchmst
277
- zrb start-server completed in 1.681591272354126 seconds
278
- 🤖 ⚠ 2023-02-22T08:02:52.911657 ⚙ 14432 ➤ 1 of 3 • 🍎 zrb start-server • 127.0.0.1 - - [22/Feb/2023 08:02:52] "HEAD / HTTP/1.1" 200 -
279
- ```
280
-
281
- # How to run tasks programmatically
282
-
283
- To run a task programmatically, you need to create a `main loop`.
284
-
285
- For example:
286
-
287
- ```python
288
- from zrb import CmdTask
289
-
290
-
291
- cmd_task = CmdTask(
292
- name='sample',
293
- cmd='echo hello'
294
- )
295
- main_loop = cmd_task.create_main_loop(env_prefix='')
296
- result = main_loop() # This run the task
297
- print(result.output) # Should be "hello"
298
- ```
299
-
300
-
301
- # Enable shell completion
302
-
303
- To enable shell completion, you need to set `_ZRB_COMPLETE` variable.
304
-
305
- For `bash`:
306
-
307
- ```bash
308
- eval $(_ZRB_COMPLETE=bash_source zrb)
309
- ```
310
-
311
- For `zsh`:
312
-
313
- ```bash
314
- eval $(_ZRB_COMPLETE=zsh_source zrb)
315
- ```
316
-
317
- Once set, you will have a shell completion in your session:
318
-
319
- ```bash
320
- zrb <TAB>
321
- zrb md5 hash -<TAB>
322
- ```
323
-
324
- Visit [click shell completion](https://click.palletsprojects.com/en/8.1.x/shell-completion/) for more information.
325
-
326
- # Configuration
327
-
328
- The following configurations are available:
329
-
330
- - `ZRB_HOME_DIR`: Zrb home directory.
331
- - Default: Zrb home directory
332
- - `ZRB_LOGGING_LEVEL`: Logging verbosity.
333
- - Default: `WARNING`
334
- - Possible values:
335
- - `CRITICAL`
336
- - `ERROR`
337
- - `WARNING`
338
- - `WARN` (The same as `WARNING`)
339
- - `INFO`
340
- - `DEBUG`
341
- - `NOTSET`
342
- - `ZRB_INIT_SCRIPTS`: List of task registration script that should be loaded by default.
343
- - Default: Empty
344
- - Possible values: List of script paths, separated by colons(`:`).
345
- - Example: `~/personal/zrb_init.py:~/work/zrb_init.py`
346
- - `ZRB_ENV`: Environment prefix that will be used when loading Operating System's environment.
347
- - Default: Empty
348
- - Possible values: Any combination of alpha-numeric and underscore
349
- - Example: `DEV`
350
- - `ZRB_SHOULD_LOAD_BUILTIN`: Whether load builtin tasks or not
351
- - Default: `1`
352
- - Possible values:
353
- - `1`
354
- - `0`
355
- - `ZRB_SHELL`: Default shell for running cmdTask
356
- - Default: `bash`
357
- - Possible value:
358
- - `/usr/bin/bash`
359
- - `/usr/bin/sh`
360
- - `ZRB_SHOW_ADVERTISEMENT`: Whether show advertisement or not.
361
- - Default: `1`
362
- - Possible value:
363
- - `1`
364
- - `0`
365
- - `ZRB_SHOW_PROMPT`: Whether show prompt or not.
366
- - Default: `1`
367
- - Possible value:
368
- - `1`
369
- - `0`
370
-
371
- # Quirks
372
-
373
- - No one is sure how to pronounce Zrb. Let's keep it that way.
374
- - If not set, `PYTHONUNBUFFERED` will be set to `1`.
375
- - Once `zrb_init.py` is loaded, Zrb will automatically:
376
- - Set `ZRB_PROJECT_DIR` to `zrb_init.py`'s parent directory.
377
- - If loaded as CLI, Zrb will also:
378
- - Adding `ZRB_PROJECT_DIR` to `PYTHONPATH`.
379
- - Zrb passes several keyword arguments that will be accessible from the task's run method:
380
- - `_args`: Shell argument when the task is invoked.
381
- - `_task`: Reference to the current task.
382
- - You can access the built-in command groups by importing `zrb.builtin_group`.
383
- - How environments are loaded:
384
- - `env_files` has the lowest priority, it will be overridden by `env`
385
- - `env` will override each other, the last one takes greater priority
386
- - If you define a `DockerComposeTask`, it will automatically fill your environment with the ones you use in your docker-compose file. The environment defined that way will have a very low priority. They will be overridden by both `env_files` and `env`.
387
-
388
- # For contributors
389
-
390
- There is a toolkit you can use to test whether Zrb is working as intended.
391
-
392
- To use the toolkit, you can invoke the following command:
393
-
394
- ```bash
395
- source ./project.sh
396
- ```
397
-
398
- Once you load the toolkit, you can start playing around.
399
-
400
- ```bash
401
- # Run test and serve coverage.
402
- zrb test
403
-
404
- # Test zrb in playground
405
- zrb prepare-playground
406
- ```
407
-
408
-
409
- # For maintainers
410
-
411
- To publish Zrb, you need a `Pypi` account:
412
-
413
- - Log in or register to [https://pypi.org/](https://pypi.org/)
414
- - Create an API token
415
-
416
- You can also create a `TestPypi` account:
417
-
418
- - Log in or register to [https://test.pypi.org/](https://test.pypi.org/)
419
- - Create an API token
420
-
421
- Once you have your API token, you need to create a `~/.pypirc` file:
422
-
423
- ```
424
- [distutils]
425
- index-servers =
426
- pypi
427
- testpypi
428
-
429
- [pypi]
430
- repository = https://upload.pypi.org/legacy/
431
- username = __token__
432
- password = pypi-xxx-xxx
433
- [testpypi]
434
- repository = https://test.pypi.org/legacy/
435
- username = __token__
436
- password = pypi-xxx-xxx
437
- ```
438
-
439
- To publish Zrb, you can do the following:
440
-
441
- ```bash
442
- source ./project.sh
443
-
444
- # Publish Zrb to TestPypi
445
- zrb publish-test
446
-
447
- # Publish Zrb to Pypi
448
- zrb publish
449
- ```
450
-
File without changes
File without changes