devscript 0.1.1__py3-none-any.whl → 0.2.0__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.
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: devscript
3
- Version: 0.1.1
4
- Summary: A utility for managing custom development scripts via JSON or TOML configuration
3
+ Version: 0.2.0
4
+ Summary: A utility for managing custom development scripts pyproject.toml configuration
5
5
  Author-email: "Маг Ильяс DOMA (MagIlyasDOMA)" <magilyas.doma.09@list.ru>
6
6
  License: GPL-3.0-only
7
7
  Project-URL: Homepage, https://github.com/MagIlyasDOMA/devscript
@@ -9,19 +9,15 @@ Project-URL: Repository, https://github.com/MagIlyasDOMA/devscript.git
9
9
  Project-URL: BugTracker, https://github.com/MagIlyasDOMA/devscript/issues
10
10
  Keywords: cli,scripts
11
11
  Classifier: Programming Language :: Python :: 3
12
- Classifier: Programming Language :: Python :: 3.8
13
- Classifier: Programming Language :: Python :: 3.9
14
- Classifier: Programming Language :: Python :: 3.10
15
12
  Classifier: Programming Language :: Python :: 3.11
16
13
  Classifier: Programming Language :: Python :: 3.12
17
14
  Classifier: Programming Language :: Python :: 3.13
18
15
  Classifier: Programming Language :: Python :: 3.14
19
16
  Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
20
17
  Classifier: Operating System :: OS Independent
21
- Requires-Python: >=3.8
18
+ Requires-Python: >=3.11
22
19
  Description-Content-Type: text/markdown
23
20
  License-File: LICENSE
24
- Requires-Dist: pyyaml>=6.0.3
25
21
  Dynamic: license-file
26
22
 
27
23
  <a id="doc_en"></a>
@@ -45,66 +41,15 @@ cd devscript
45
41
  pip install -e .
46
42
  ```
47
43
 
48
- ### TypeScript version
49
- ```shell
50
- npm install -D @hren/devscript
51
- # or
52
- yarn add -D @hren/devscript
53
- # or
54
- pnpm add -D @hren/devscript
55
- ```
56
-
57
- #### Or install from source:
58
-
59
- ```shell
60
- git clone https://github.com/MagIlyasDOMA/devscript.git
61
- cd devscript
62
- npm install
63
- npm run build
64
- npm link
65
- ```
66
-
67
- ### Configuration formats
68
- #### JSON (`devscript.json`)
69
- ```json
70
- {
71
- "$schema": "https://raw.githubusercontent.com/MagIlyasDOMA/devscript/refs/heads/main/schema.json",
72
- "build": "python -m build",
73
- "test": "pytest tests/",
74
- "lint": "flake8 src/",
75
- "dev": "python -m app --debug"
76
- }
77
- ```
78
-
79
- #### YAML (`devscript.yaml`)
80
- ```yaml
81
- build: "python -m build"
82
- test: "pytest tests/"
83
- lint: "flake8 src/"
84
- dev: "python -m app --debug"
85
- ```
86
-
87
- #### TOML (`pyproject.toml`)
44
+ ### Configuration format
88
45
  ```toml
89
- [devscript]
46
+ [tool.devscript]
90
47
  build = "python -m build"
91
48
  test = "pytest tests/"
92
49
  lint = "flake8 src/"
93
50
  dev = "python -m app --debug"
94
51
  ```
95
52
 
96
- #### `package.json`
97
- ```json
98
- {
99
- "devscript": {
100
- "build": "python -m build",
101
- "test": "pytest tests/",
102
- "lint": "flake8 src/",
103
- "dev": "python -m app --debug"
104
- }
105
- }
106
- ```
107
-
108
53
  ### Running commands
109
54
  #### The package provides four CLI commands:
110
55
  - `devscript` — full name
@@ -126,13 +71,12 @@ dvs lint
126
71
  # Pass arguments to a command
127
72
  devscript dev --port 8000 --reload
128
73
  ```
129
- Here is the translation of the text into English, with the markdown formatting preserved:
130
74
 
131
75
  ## Examples
132
76
  ### Example 1: Basic usage
133
77
  ```toml
134
78
  # pyproject.toml
135
- [devscript]
79
+ [tool.devscript]
136
80
  start = "uvicorn main:app --reload"
137
81
  migrate = "alembic upgrade head"
138
82
  shell = "ipython"
@@ -145,11 +89,10 @@ devs shell # Starts IPython
145
89
  ```
146
90
 
147
91
  ### Example 2: Passing arguments
148
- ```json
149
- {
150
- "test": "pytest",
151
- "cov": "pytest --cov=src"
152
- }
92
+ ```toml
93
+ [tool.devscript]
94
+ test = "pytest"
95
+ cov = "pytest --cov=src"
153
96
  ```
154
97
 
155
98
  ```shell
@@ -174,42 +117,12 @@ devs test
174
117
  devs lint
175
118
  ```
176
119
 
177
- ### TypeScript version
178
- ```shell
179
- # Clone the repository
180
- git clone https://github.com/MagIlyasDOMA/devscript.git
181
- cd devscript
182
-
183
- # Install dependencies
184
- npm install
185
-
186
- # Build the project
187
- npm run build
188
-
189
- # Install in development mode
190
- npm link
191
-
192
- # Run tests
193
- devs test
194
-
195
- # Run linter
196
- devs lint
197
- ```
198
-
199
120
  ## Project structure
200
121
  ```text
201
122
  devscript/
202
- ├── python/ # Python implementation
203
- ├── devscript/
204
- │ │ ├── __init__.py
205
- │ │ └── py.typed
206
- │ ├── pyproject.toml
207
- │ └── README.md
208
- ├── typescript/ # TypeScript implementation
209
- │ ├── devscript.ts
210
- │ ├── package.json
211
- │ ├── tsconfig.json
212
- │ └── README.md
123
+ ├── devscript.py # Python implementation
124
+ ├── pyproject.toml
125
+ ├── README.md
213
126
  ├── schema.json # JSON Schema for autocompletion
214
127
  └── LICENSE
215
128
  ```
@@ -233,25 +146,11 @@ print("Available commands:", core.commands_list())
233
146
  core.run("build", ["--verbose"])
234
147
  ```
235
148
 
236
- #### Typescript
237
- ```typescript
238
- import { DevScriptCore } from 'devscript';
239
- ```
240
- ```javascript
241
- const core = new DevScriptCore();
242
- console.log("Available commands:", core.commands_list());
243
- core.run("build", ["--verbose"]);
244
- ```
245
-
246
149
  ## Requirements
247
150
  ### Python version
248
- - Python 3.8 or higher
151
+ - Python 3.11 or higher
249
152
  - No external dependencies (uses the standard library)
250
153
 
251
- ### TypeScript version
252
- - Node.js 14 or higher
253
- - Dependencies: argparse, smol-toml
254
-
255
154
  ## License
256
155
  GPL-3.0-only
257
156
 
@@ -267,20 +166,6 @@ GPL-3.0-only
267
166
  4. Push to the branch (`git push origin feature/amazing-feature`)
268
167
  5. Open a Pull Request
269
168
 
270
- ## Frequently Asked Questions
271
- ##### Q: Can I use both versions at the same time?
272
- A: Yes, they do not conflict as they use different commands for installation (pip vs npm).
273
-
274
- ##### Q: Are other configuration formats supported?
275
- A: Currently, JSON, YAML, pyproject.toml, and package.json are supported.
276
-
277
- ##### Q: How do I add a new command?
278
- A: Just add a new entry in the configuration file with the command name and the corresponding shell command.
279
-
280
- ##### Q: Does it work on Windows?
281
- A: Yes, both versions have been tested on Windows.
282
-
283
-
284
169
  ---
285
170
 
286
171
  <a id="doc_ru"></a>
@@ -304,66 +189,15 @@ cd devscript
304
189
  pip install -e .
305
190
  ```
306
191
 
307
- ### TypeScript версия
308
- ```shell
309
- npm install -D @hren/devscript
310
- # или
311
- yarn add -D @hren/devscript
312
- # или
313
- pnpm add -D @hren/devscript
314
- ```
315
-
316
- #### Или установка из исходного кода:
317
-
318
- ```shell
319
- git clone https://github.com/MagIlyasDOMA/devscript.git
320
- cd devscript
321
- npm install
322
- npm run build
323
- npm link
324
- ```
325
-
326
- ### Форматы конфигурации
327
- #### JSON (`devscript.json`)
328
- ```json
329
- {
330
- "$schema": "https://raw.githubusercontent.com/MagIlyasDOMA/devscript/refs/heads/main/schema.json",
331
- "build": "python -m build",
332
- "test": "pytest tests/",
333
- "lint": "flake8 src/",
334
- "dev": "python -m app --debug"
335
- }
336
- ```
337
-
338
- #### YAML (`devscript.yaml`)
339
- ```yaml
340
- build: "python -m build"
341
- test: "pytest tests/"
342
- lint: "flake8 src/"
343
- dev: "python -m app --debug"
344
- ```
345
-
346
- #### TOML (`pyproject.toml`)
192
+ ### Формат конфигурации
347
193
  ```toml
348
- [devscript]
194
+ [tool.devscript]
349
195
  build = "python -m build"
350
196
  test = "pytest tests/"
351
197
  lint = "flake8 src/"
352
198
  dev = "python -m app --debug"
353
199
  ```
354
200
 
355
- #### `package.json`
356
- ```json
357
- {
358
- "devscript": {
359
- "build": "python -m build",
360
- "test": "pytest tests/",
361
- "lint": "flake8 src/",
362
- "dev": "python -m app --debug"
363
- }
364
- }
365
- ```
366
-
367
201
  ### Запуск команд
368
202
  #### Пакет предоставляет четыре CLI-команды:
369
203
  - `devscript` — полное имя
@@ -390,7 +224,7 @@ devscript dev --port 8000 --reload
390
224
  ### Пример 1: Базовое использование
391
225
  ```toml
392
226
  # pyproject.toml
393
- [devscript]
227
+ [tool.devscript]
394
228
  start = "uvicorn main:app --reload"
395
229
  migrate = "alembic upgrade head"
396
230
  shell = "ipython"
@@ -403,11 +237,10 @@ devs shell # Запускает IPython
403
237
  ```
404
238
 
405
239
  ### Пример 2: Передача аргументов
406
- ```json
407
- {
408
- "test": "pytest",
409
- "cov": "pytest --cov=src"
410
- }
240
+ ```toml
241
+ [tool.devscript]
242
+ test = "pytest"
243
+ cov = "pytest --cov=src"
411
244
  ```
412
245
 
413
246
  ```shell
@@ -432,42 +265,12 @@ devs test
432
265
  devs lint
433
266
  ```
434
267
 
435
- ### TypeScript версия
436
- ```shell
437
- # Клонировать репозиторий
438
- git clone https://github.com/MagIlyasDOMA/devscript.git
439
- cd devscript
440
-
441
- # Установить зависимости
442
- npm install
443
-
444
- # Собрать проект
445
- npm run build
446
-
447
- # Установить в режиме разработки
448
- npm link
449
-
450
- # Запустить тесты
451
- devs test
452
-
453
- # Запустить линтер
454
- devs lint
455
- ```
456
-
457
268
  ## Структура проекта
458
269
  ```text
459
270
  devscript/
460
- ├── python/ # Python реализация
461
- ├── devscript/
462
- │ │ ├── __init__.py
463
- │ │ └── py.typed
464
- │ ├── pyproject.toml
465
- │ └── README.md
466
- ├── typescript/ # TypeScript реализация
467
- │ ├── devscript.ts
468
- │ ├── package.json
469
- │ ├── tsconfig.json
470
- │ └── README.md
271
+ ├── devscript.py # Python-реализация
272
+ ├── pyproject.toml
273
+ ├── README.md
471
274
  ├── schema.json # JSON Schema для автодополнения
472
275
  └── LICENSE
473
276
  ```
@@ -491,24 +294,11 @@ print("Доступные команды:", core.commands_list())
491
294
  core.run("build", ["--verbose"])
492
295
  ```
493
296
 
494
- #### Typescript
495
- ```typescript
496
- import { DevScriptCore } from 'devscript';
497
-
498
- const core = new DevScriptCore();
499
- console.log("Доступные команды:", core.commands_list());
500
- core.run("build", ["--verbose"]);
501
- ```
502
-
503
297
  ## Требования
504
298
  ### Python версия
505
- - Python 3.8 или выше
299
+ - Python 3.11 или выше
506
300
  - Нет внешних зависимостей (использует стандартную библиотеку)
507
301
 
508
- ### TypeScript версия
509
- - Node.js 14 или выше
510
- - Зависимости: argparse, smol-toml
511
-
512
302
  ## Лицензия
513
303
  GPL-3.0-only
514
304
 
@@ -523,16 +313,3 @@ GPL-3.0-only
523
313
  3. Закоммитьте изменения (`git commit -m 'Add some amazing feature'`)
524
314
  4. Запушьте в ветку (`git push origin feature/amazing-feature`)
525
315
  5. Откройте Pull Request
526
-
527
- ## Часто задаваемые вопросы
528
- ##### Q: Могу ли я использовать обе версии одновременно?
529
- A: Да, они не конфликтуют, так как используют разные команды для установки (pip vs npm).
530
-
531
- ##### Q: Поддерживаются ли другие форматы конфигурации?
532
- A: В данный момент поддерживаются JSON, YAML, pyproject.toml и package.json
533
-
534
- ##### Q: Как добавить новую команду?
535
- A: Просто добавьте новую запись в конфигурационный файл с именем команды и соответствующей shell-командой.
536
-
537
- ##### Q: Работает ли на Windows?
538
- A: Да, обе версии протестированы на Windows.
@@ -0,0 +1,7 @@
1
+ devscript.py,sha256=_M_bjoTv_u8cw8GSJ4lU4_1JmoZtCCW16SYv5TpddwA,1128
2
+ devscript-0.2.0.dist-info/licenses/LICENSE,sha256=IwGE9guuL-ryRPEKi6wFPI_zOhg7zDZbTYuHbSt_SAk,35823
3
+ devscript-0.2.0.dist-info/METADATA,sha256=AosfxA0RuhHEHxWg-lHABMyAXoQBMP_J7WrxQwY7IRI,8404
4
+ devscript-0.2.0.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
5
+ devscript-0.2.0.dist-info/entry_points.txt,sha256=npG9JMkfk8V9pQZwLKU1mb5L7P5nceGF7gB4VuSEM1c,112
6
+ devscript-0.2.0.dist-info/top_level.txt,sha256=Tk3VhyXXyXV8jxju8RTKMKYivzFb_496RWF5YfocI5g,10
7
+ devscript-0.2.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (82.0.1)
2
+ Generator: setuptools (83.0.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
devscript.py ADDED
@@ -0,0 +1,35 @@
1
+ import argparse, os, tomllib
2
+ from dataclasses import dataclass
3
+ from typing import Literal
4
+
5
+ __version__ = '0.2.0'
6
+
7
+
8
+ class DevScriptCore:
9
+ def __init__(self):
10
+ try: self.config = self.read_config()['tool']['devscript']
11
+ except KeyError: raise FileNotFoundError('Config not found')
12
+
13
+ @staticmethod
14
+ def read_config() -> dict:
15
+ if os.path.isfile('pyproject.toml'):
16
+ with open('pyproject.toml', 'rb') as file: return tomllib.load(file)
17
+ else: raise FileNotFoundError('Config not found')
18
+
19
+ def commands_list(self): return self.config.keys()
20
+
21
+ def run(self, command: str, argv: list[str]):
22
+ if command not in self.commands_list():
23
+ raise ValueError(f'Invalid command: {command}')
24
+ os.system(' '.join([self.config[command]] + argv))
25
+
26
+
27
+ def main():
28
+ core = DevScriptCore()
29
+ parser = argparse.ArgumentParser()
30
+ parser.add_argument('command', type=str, help='script to run', choices=core.commands_list())
31
+ args, argv = parser.parse_known_args()
32
+ core.run(args.command, argv)
33
+
34
+
35
+ if __name__ == '__main__': main()
devscript/__init__.py DELETED
@@ -1,69 +0,0 @@
1
- import argparse, os, json, tomllib, yaml
2
- from dataclasses import dataclass
3
- from typing import Literal
4
-
5
- __version__ = '0.1.0'
6
-
7
-
8
- @dataclass
9
- class DevScriptConfig:
10
- type: Literal['json', 'toml', 'npmjs', 'yaml']
11
- data: dict
12
-
13
-
14
- class DevScriptCore:
15
- def __init__(self):
16
- self._config_obj = self.read_config()
17
- try:
18
- if self._config_obj.type == 'json':
19
- self.config = self._config_obj.data
20
- self._config_file = 'devscript.json'
21
- elif self._config_obj.type == 'yaml':
22
- self.config = self._config_obj.data
23
- self._config_file = 'devscript.yaml'
24
- elif self._config_obj.type == 'toml':
25
- self.config = self._config_obj.data['devscript']
26
- self._config_file = 'pyproject.toml'
27
- elif self._config_obj.type == 'npmjs':
28
- self.config = self._config_obj.data['devscript']
29
- self._config_file = 'package.json'
30
- else: raise FileNotFoundError('Config not found')
31
- except KeyError:
32
- raise FileNotFoundError('Config not found')
33
-
34
- @staticmethod
35
- def read_config() -> DevScriptConfig:
36
- if os.path.isfile('devscript.json'):
37
- with open('devscript.json', encoding='utf-8') as file:
38
- data = json.load(file)
39
- if '$schema' in data: del data['$schema']
40
- return DevScriptConfig('json', data)
41
- elif os.path.isfile('devscript.yaml'):
42
- with open('devscript.yaml', encoding='utf-8') as file:
43
- return DevScriptConfig('yaml', yaml.safe_load(file))
44
- elif os.path.isfile('pyproject.toml'):
45
- with open('pyproject.toml', 'rb') as file:
46
- return DevScriptConfig('toml', tomllib.load(file))
47
- elif os.path.isfile('package.json'):
48
- with open('package.json', 'r', encoding='utf-8') as file:
49
- return DevScriptConfig('npmjs', json.load(file))
50
- else: raise FileNotFoundError('Config not found')
51
-
52
- def commands_list(self):
53
- return self.config.keys()
54
-
55
- def run(self, command: str, argv: list[str]):
56
- if command not in self.commands_list():
57
- raise ValueError(f'Invalid command: {command}')
58
- os.system(' '.join([self.config[command]] + argv))
59
-
60
-
61
- def main():
62
- core = DevScriptCore()
63
- parser = argparse.ArgumentParser()
64
- parser.add_argument('command', type=str, help='script to run', choices=core.commands_list())
65
- args, argv = parser.parse_known_args()
66
- core.run(args.command, argv)
67
-
68
-
69
- if __name__ == '__main__': main()
@@ -1,7 +0,0 @@
1
- devscript/__init__.py,sha256=TdCIcN4tQLTCQXxZH-Vb6nKg1Z9b38VV9NQDHWnUH7c,2672
2
- devscript-0.1.1.dist-info/licenses/LICENSE,sha256=IwGE9guuL-ryRPEKi6wFPI_zOhg7zDZbTYuHbSt_SAk,35823
3
- devscript-0.1.1.dist-info/METADATA,sha256=lYerkXe3OeJyorb3h0O_BS8c_Ymcr8f5SjTQxmJGVrk,14005
4
- devscript-0.1.1.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
5
- devscript-0.1.1.dist-info/entry_points.txt,sha256=npG9JMkfk8V9pQZwLKU1mb5L7P5nceGF7gB4VuSEM1c,112
6
- devscript-0.1.1.dist-info/top_level.txt,sha256=Tk3VhyXXyXV8jxju8RTKMKYivzFb_496RWF5YfocI5g,10
7
- devscript-0.1.1.dist-info/RECORD,,