create-marp-presentation 1.0.1
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/LICENSE +21 -0
- package/README.md +34 -0
- package/index.js +96 -0
- package/package.json +46 -0
- package/template/README.md +57 -0
- package/template/marp.config.js +4 -0
- package/template/package.json +22 -0
- package/template/presentation.md +50 -0
- package/template/scripts/copy-static.js +48 -0
- package/template/static/.gitkeep +0 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Create Marp Presentation
|
|
2
|
+
|
|
3
|
+
Создайте новую Marp презентацию одной командой.
|
|
4
|
+
|
|
5
|
+
## Установка
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npx create-marp-presentation my-presentation
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Использование
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
cd my-presentation
|
|
15
|
+
npm run dev # Live preview
|
|
16
|
+
npm run build:all # Build all formats
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Возможности
|
|
20
|
+
|
|
21
|
+
- 🚀 One-command setup
|
|
22
|
+
- 📝 Markdown slides
|
|
23
|
+
- 🎨 Marp themes
|
|
24
|
+
- 📦 HTML, PDF, PPTX export
|
|
25
|
+
- 📁 Static files support
|
|
26
|
+
- 🔥 Live preview
|
|
27
|
+
|
|
28
|
+
## Документация
|
|
29
|
+
|
|
30
|
+
После создания проекта читайте README в папке проекта.
|
|
31
|
+
|
|
32
|
+
## Лицензия
|
|
33
|
+
|
|
34
|
+
MIT
|
package/index.js
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const { spawnSync } = require('child_process');
|
|
6
|
+
|
|
7
|
+
const projectName = process.argv[2];
|
|
8
|
+
|
|
9
|
+
if (!projectName) {
|
|
10
|
+
console.error('Please provide a project name:');
|
|
11
|
+
console.error(' npx create-marp-presentation <project-name>');
|
|
12
|
+
process.exit(1);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// Валидация имени проекта
|
|
16
|
+
const validName = /^[a-z0-9][a-z0-9-]*[a-z0-9]$|^[a-z0-9]$/;
|
|
17
|
+
if (!validName.test(projectName)) {
|
|
18
|
+
console.error(`Invalid project name: "${projectName}"`);
|
|
19
|
+
console.error('Project name must be lowercase, contain only letters, numbers, and hyphens.');
|
|
20
|
+
process.exit(1);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const projectPath = path.join(process.cwd(), projectName);
|
|
24
|
+
|
|
25
|
+
// Validate path to prevent traversal attacks
|
|
26
|
+
const resolvedPath = path.resolve(projectPath);
|
|
27
|
+
if (!resolvedPath.startsWith(path.resolve(process.cwd()))) {
|
|
28
|
+
console.error('Invalid project path: path traversal detected.');
|
|
29
|
+
process.exit(1);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Проверка существования папки
|
|
33
|
+
if (fs.existsSync(projectPath)) {
|
|
34
|
+
console.error(`Directory "${projectName}" already exists.`);
|
|
35
|
+
process.exit(1);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Получаем путь к template
|
|
39
|
+
const templatePath = path.join(__dirname, 'template');
|
|
40
|
+
|
|
41
|
+
console.log(`Creating Marp presentation: ${projectName}`);
|
|
42
|
+
console.log();
|
|
43
|
+
|
|
44
|
+
try {
|
|
45
|
+
// Создаём папку проекта
|
|
46
|
+
fs.mkdirSync(projectPath, { recursive: true });
|
|
47
|
+
|
|
48
|
+
// Рекурсивно копируем template
|
|
49
|
+
const copyDir = (src, dest) => {
|
|
50
|
+
const entries = fs.readdirSync(src, { withFileTypes: true });
|
|
51
|
+
|
|
52
|
+
for (const entry of entries) {
|
|
53
|
+
const srcPath = path.join(src, entry.name);
|
|
54
|
+
const destPath = path.join(dest, entry.name);
|
|
55
|
+
|
|
56
|
+
if (entry.isDirectory()) {
|
|
57
|
+
fs.mkdirSync(destPath, { recursive: true });
|
|
58
|
+
copyDir(srcPath, destPath);
|
|
59
|
+
} else {
|
|
60
|
+
fs.copyFileSync(srcPath, destPath);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
copyDir(templatePath, projectPath);
|
|
66
|
+
|
|
67
|
+
console.log('✓ Project created');
|
|
68
|
+
console.log();
|
|
69
|
+
|
|
70
|
+
// Запускаем npm install
|
|
71
|
+
console.log('Installing dependencies...');
|
|
72
|
+
const installResult = spawnSync('npm', ['install'], {
|
|
73
|
+
cwd: projectPath,
|
|
74
|
+
stdio: 'inherit',
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
if (installResult.status !== 0) {
|
|
78
|
+
console.error();
|
|
79
|
+
console.error('Failed to install dependencies.');
|
|
80
|
+
console.error('Please run "cd ' + projectName + ' && npm install" manually.');
|
|
81
|
+
process.exit(1);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
console.log();
|
|
85
|
+
console.log('✓ Dependencies installed');
|
|
86
|
+
console.log();
|
|
87
|
+
console.log('Next steps:');
|
|
88
|
+
console.log(` cd ${projectName}`);
|
|
89
|
+
console.log(' npm run dev # Start live preview');
|
|
90
|
+
console.log(' npm run build:all # Build all formats');
|
|
91
|
+
console.log();
|
|
92
|
+
|
|
93
|
+
} catch (err) {
|
|
94
|
+
console.error('Error creating project:', err.message);
|
|
95
|
+
process.exit(1);
|
|
96
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "create-marp-presentation",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Create a new Marp presentation project with one command",
|
|
5
|
+
"bin": {
|
|
6
|
+
"create-marp-presentation": "index.js"
|
|
7
|
+
},
|
|
8
|
+
"files": [
|
|
9
|
+
"index.js",
|
|
10
|
+
"template/"
|
|
11
|
+
],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"test": "jest"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"marp",
|
|
17
|
+
"presentation",
|
|
18
|
+
"markdown",
|
|
19
|
+
"slides",
|
|
20
|
+
"template",
|
|
21
|
+
"cli"
|
|
22
|
+
],
|
|
23
|
+
"author": "",
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "git+https://github.com/echernyshev/marp-presentation-template.git"
|
|
28
|
+
},
|
|
29
|
+
"homepage": "https://github.com/echernyshev/marp-presentation-template#readme",
|
|
30
|
+
"bugs": {
|
|
31
|
+
"url": "https://github.com/echernyshev/marp-presentation-template/issues"
|
|
32
|
+
},
|
|
33
|
+
"engines": {
|
|
34
|
+
"node": ">=20.0.0"
|
|
35
|
+
},
|
|
36
|
+
"jest": {
|
|
37
|
+
"testEnvironment": "node",
|
|
38
|
+
"testMatch": [
|
|
39
|
+
"**/tests/**/*.test.js"
|
|
40
|
+
]
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"fast-glob": "^3.3.3",
|
|
44
|
+
"jest": "^29.7.0"
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# Marp Presentation
|
|
2
|
+
|
|
3
|
+
Шаблон для создания презентаций с Marp.
|
|
4
|
+
|
|
5
|
+
## Начало работы
|
|
6
|
+
|
|
7
|
+
### Live-предпросмотр
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm run dev
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Откроется браузер с автообновлением при изменениях.
|
|
14
|
+
|
|
15
|
+
### Создание слайдов
|
|
16
|
+
|
|
17
|
+
Редактируйте `presentation.md` — это главный файл презентации.
|
|
18
|
+
|
|
19
|
+
## Сборка презентации
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm run build:html # HTML презентация (интерактивная)
|
|
23
|
+
npm run build:pdf # PDF файл
|
|
24
|
+
npm run build:pptx # PowerPoint
|
|
25
|
+
npm run build:all # Все форматы сразу
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Результат появится в папке `output/`.
|
|
29
|
+
|
|
30
|
+
## Статические файлы
|
|
31
|
+
|
|
32
|
+
Поместите изображения и другие файлы в папку, указанную в `marp.config.js`.
|
|
33
|
+
|
|
34
|
+
По умолчанию: `static/`
|
|
35
|
+
|
|
36
|
+
Вы можете добавить дополнительные папки в `marp.config.js`:
|
|
37
|
+
|
|
38
|
+
```javascript
|
|
39
|
+
module.exports = {
|
|
40
|
+
staticFolders: ['static/**', 'assets/**', 'images/**'],
|
|
41
|
+
outputDir: 'output',
|
|
42
|
+
};
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Очистка
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
npm run clean
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Удаляет папку `output/`.
|
|
52
|
+
|
|
53
|
+
## Полезные ссылки
|
|
54
|
+
|
|
55
|
+
- [Marp Documentation](https://marp.app/)
|
|
56
|
+
- [Marp CLI](https://github.com/marp-team/marp-cli)
|
|
57
|
+
- [Markdown Guide](https://www.markdownguide.org/)
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "marp-presentation",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Marp presentation",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"dev": "marp -s . --html --allow-local-files",
|
|
7
|
+
"build:html": "marp presentation.md -o output/index.html --html && npm run copy:static",
|
|
8
|
+
"build:pdf": "marp presentation.md -o output/presentation.pdf --allow-local-files && npm run copy:static",
|
|
9
|
+
"build:pptx": "marp presentation.md -o output/presentation.pptx --allow-local-files && npm run copy:static",
|
|
10
|
+
"build:all": "npm run build:html && npm run build:pdf && npm run build:pptx",
|
|
11
|
+
"copy:static": "node scripts/copy-static.js",
|
|
12
|
+
"clean": "rimraf output"
|
|
13
|
+
},
|
|
14
|
+
"devDependencies": {
|
|
15
|
+
"@marp-team/marp-cli": "^4.1.2",
|
|
16
|
+
"fast-glob": "^3.3.3",
|
|
17
|
+
"rimraf": "^6.0.0"
|
|
18
|
+
},
|
|
19
|
+
"engines": {
|
|
20
|
+
"node": ">=20.0.0"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
---
|
|
2
|
+
marp: true
|
|
3
|
+
theme: default
|
|
4
|
+
paginate: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Моя презентация
|
|
8
|
+
|
|
9
|
+
Добро пожаловать в вашу новую Marp презентацию!
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## О Marp
|
|
14
|
+
|
|
15
|
+
Marp (Markdown Presentation Ecosystem) — это инструмент для создания презентаций на Markdown.
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Возможности
|
|
20
|
+
|
|
21
|
+
- **Простой Markdown** - пишите слайды в привычном формате
|
|
22
|
+
- **Темы** - используйте встроенные или создайте свою
|
|
23
|
+
- **Экспорт** - HTML, PDF, PowerPoint
|
|
24
|
+
- **Live preview** - мгновенный предпросмотр изменений
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Код с подсветкой
|
|
29
|
+
|
|
30
|
+
```javascript
|
|
31
|
+
function hello() {
|
|
32
|
+
console.log('Hello, Marp!');
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## Изображения
|
|
39
|
+
|
|
40
|
+
Поместите изображения в папку `static/` и используйте их:
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+

|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
# Вопросы?
|
|
49
|
+
|
|
50
|
+
Документация: https://marp.app/
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const { globSync } = require('fast-glob');
|
|
4
|
+
|
|
5
|
+
// Читаем конфиг с дефолтными значениями
|
|
6
|
+
let config;
|
|
7
|
+
try {
|
|
8
|
+
config = require('../marp.config.js');
|
|
9
|
+
} catch {
|
|
10
|
+
config = {};
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const outputDir = config.outputDir || 'output';
|
|
14
|
+
const staticFolders = config.staticFolders || ['static/**'];
|
|
15
|
+
|
|
16
|
+
// Создаём output если нет
|
|
17
|
+
if (!fs.existsSync(outputDir)) {
|
|
18
|
+
fs.mkdirSync(outputDir, { recursive: true });
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Находим файлы по паттернам
|
|
22
|
+
const files = globSync(staticFolders);
|
|
23
|
+
|
|
24
|
+
if (files.length === 0) {
|
|
25
|
+
console.log('No static files found to copy.');
|
|
26
|
+
process.exit(0);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Копируем с сохранением структуры
|
|
30
|
+
let copied = 0;
|
|
31
|
+
for (const file of files) {
|
|
32
|
+
const relativePath = path.relative(process.cwd(), file);
|
|
33
|
+
const destPath = path.join(outputDir, relativePath);
|
|
34
|
+
|
|
35
|
+
const destDir = path.dirname(destPath);
|
|
36
|
+
if (!fs.existsSync(destDir)) {
|
|
37
|
+
fs.mkdirSync(destDir, { recursive: true });
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
try {
|
|
41
|
+
fs.copyFileSync(file, destPath);
|
|
42
|
+
copied++;
|
|
43
|
+
} catch (err) {
|
|
44
|
+
console.warn(`Warning: Could not copy ${file}: ${err.message}`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
console.log(`✓ Copied ${copied} file(s) to ${outputDir}/`);
|
|
File without changes
|