dokio-create-template 1.0.2 ā 1.1.3
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 +1 -1
- package/README.md +153 -43
- package/bin/cli.js +1 -1
- package/dist/creator.d.ts +2 -0
- package/dist/creator.d.ts.map +1 -0
- package/dist/creator.js +170 -0
- package/dist/creator.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +32 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/package.json +35 -5
- package/templates/email/CHANGELOG.md +1 -0
- package/templates/general/CHANGELOG.md +1 -0
- package/templates/general/data.yaml +7 -10
- package/templates/general/index.html +14 -15
- package/templates/general/style.scss.hbs +2 -3
- package/templates/pdf/CHANGELOG.md +1 -0
- package/templates/pdf/index.html +14 -14
- package/templates/pdf/style.scss.hbs +1 -8
- package/EXAMPLES.md +0 -609
- package/INSTALLATION.md +0 -516
- package/QUICKSTART.md +0 -218
- package/SETUP.md +0 -192
- package/STRUCTURE.txt +0 -0
- package/index.js +0 -1
- package/lib/creator.js +0 -144
package/SETUP.md
DELETED
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
# Setup Guide - dokio-create-template
|
|
2
|
-
|
|
3
|
-
This guide will walk you through setting up and publishing the `dokio-create-template` npm package.
|
|
4
|
-
|
|
5
|
-
## Prerequisites
|
|
6
|
-
|
|
7
|
-
- Node.js 14.0.0 or higher
|
|
8
|
-
- npm account (for publishing)
|
|
9
|
-
|
|
10
|
-
## Installation for Development
|
|
11
|
-
|
|
12
|
-
1. **Clone or create the package directory:**
|
|
13
|
-
```bash
|
|
14
|
-
cd dokio-create-template
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
2. **Install dependencies:**
|
|
18
|
-
```bash
|
|
19
|
-
npm install
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
3. **Test the CLI locally:**
|
|
23
|
-
```bash
|
|
24
|
-
node bin/cli.js
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
Or link it globally to test:
|
|
28
|
-
```bash
|
|
29
|
-
npm link
|
|
30
|
-
dokio-create-template
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
## Publishing to npm
|
|
34
|
-
|
|
35
|
-
### First Time Setup
|
|
36
|
-
|
|
37
|
-
1. **Login to npm:**
|
|
38
|
-
```bash
|
|
39
|
-
npm login
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
2. **Verify your package name is available:**
|
|
43
|
-
```bash
|
|
44
|
-
npm search dokio-create-template
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
3. **Update package.json with your details:**
|
|
48
|
-
- Change author name
|
|
49
|
-
- Add your repository URL
|
|
50
|
-
- Verify version number
|
|
51
|
-
|
|
52
|
-
4. **Publish the package:**
|
|
53
|
-
```bash
|
|
54
|
-
npm publish
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
### Updating the Package
|
|
58
|
-
|
|
59
|
-
1. **Make your changes**
|
|
60
|
-
|
|
61
|
-
2. **Update version number:**
|
|
62
|
-
```bash
|
|
63
|
-
# For bug fixes
|
|
64
|
-
npm version patch
|
|
65
|
-
|
|
66
|
-
# For new features
|
|
67
|
-
npm version minor
|
|
68
|
-
|
|
69
|
-
# For breaking changes
|
|
70
|
-
npm version major
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
3. **Publish the update:**
|
|
74
|
-
```bash
|
|
75
|
-
npm publish
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
## Testing
|
|
79
|
-
|
|
80
|
-
### Test Template Generation
|
|
81
|
-
|
|
82
|
-
```bash
|
|
83
|
-
# Test general template
|
|
84
|
-
dokio-create-template
|
|
85
|
-
# Select: General (Image)
|
|
86
|
-
|
|
87
|
-
# Test PDF template
|
|
88
|
-
dokio-create-template
|
|
89
|
-
# Select: PDF
|
|
90
|
-
|
|
91
|
-
# Test email template
|
|
92
|
-
dokio-create-template
|
|
93
|
-
# Select: Email
|
|
94
|
-
|
|
95
|
-
# Test video template
|
|
96
|
-
dokio-create-template
|
|
97
|
-
# Select: Video
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
### Verify Output
|
|
101
|
-
|
|
102
|
-
After generation, check that all files are created:
|
|
103
|
-
- `index.html`
|
|
104
|
-
- `style.scss.hbs`
|
|
105
|
-
- `data.yaml`
|
|
106
|
-
- `CHANGELOG.md`
|
|
107
|
-
|
|
108
|
-
## Troubleshooting
|
|
109
|
-
|
|
110
|
-
### "Command not found" error
|
|
111
|
-
|
|
112
|
-
If you get a "command not found" error after global installation:
|
|
113
|
-
|
|
114
|
-
1. Check npm global bin path:
|
|
115
|
-
```bash
|
|
116
|
-
npm config get prefix
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
2. Add to your PATH (add to ~/.bashrc or ~/.zshrc):
|
|
120
|
-
```bash
|
|
121
|
-
export PATH="$PATH:$(npm config get prefix)/bin"
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
3. Reload your shell:
|
|
125
|
-
```bash
|
|
126
|
-
source ~/.bashrc # or ~/.zshrc
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
### Module not found errors
|
|
130
|
-
|
|
131
|
-
Make sure dependencies are installed:
|
|
132
|
-
```bash
|
|
133
|
-
npm install
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
### Permission errors on publish
|
|
137
|
-
|
|
138
|
-
Make sure you're logged in:
|
|
139
|
-
```bash
|
|
140
|
-
npm whoami
|
|
141
|
-
npm login
|
|
142
|
-
```
|
|
143
|
-
|
|
144
|
-
## Directory Structure
|
|
145
|
-
|
|
146
|
-
```
|
|
147
|
-
dokio-create-template/
|
|
148
|
-
āāā bin/
|
|
149
|
-
ā āāā cli.js # CLI entry point
|
|
150
|
-
āāā lib/
|
|
151
|
-
ā āāā creator.js # Main logic
|
|
152
|
-
āāā templates/
|
|
153
|
-
ā āāā general/
|
|
154
|
-
ā ā āāā index.html
|
|
155
|
-
ā ā āāā style.scss.hbs
|
|
156
|
-
ā ā āāā data.yaml
|
|
157
|
-
ā ā āāā CHANGELOG.md
|
|
158
|
-
ā āāā pdf/
|
|
159
|
-
ā ā āāā index.html
|
|
160
|
-
ā ā āāā style.scss.hbs
|
|
161
|
-
ā ā āāā data.yaml
|
|
162
|
-
ā ā āāā CHANGELOG.md
|
|
163
|
-
ā āāā email/
|
|
164
|
-
ā ā āāā index.html
|
|
165
|
-
ā ā āāā style.scss.hbs
|
|
166
|
-
ā ā āāā data.yaml
|
|
167
|
-
ā ā āāā CHANGELOG.md
|
|
168
|
-
ā āāā video/
|
|
169
|
-
ā āāā index.html
|
|
170
|
-
ā āāā style.scss.hbs
|
|
171
|
-
ā āāā data.yaml
|
|
172
|
-
ā āāā CHANGELOG.md
|
|
173
|
-
āāā index.js
|
|
174
|
-
āāā package.json
|
|
175
|
-
āāā README.md
|
|
176
|
-
āāā LICENSE
|
|
177
|
-
āāā .gitignore
|
|
178
|
-
```
|
|
179
|
-
|
|
180
|
-
## Next Steps
|
|
181
|
-
|
|
182
|
-
1. Customize the templates in the `templates/` directory to match your organization's needs
|
|
183
|
-
2. Add more template types if needed
|
|
184
|
-
3. Enhance the CLI with additional options
|
|
185
|
-
4. Add validation for template uploads
|
|
186
|
-
5. Create tests
|
|
187
|
-
|
|
188
|
-
## Support
|
|
189
|
-
|
|
190
|
-
For issues or questions:
|
|
191
|
-
- GitHub Issues: [your-repo-url]
|
|
192
|
-
- Dokio Support: https://support.dokio.com
|
package/STRUCTURE.txt
DELETED
|
File without changes
|
package/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = require('./lib/creator');
|
package/lib/creator.js
DELETED
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
const inquirer = require('inquirer');
|
|
2
|
-
const chalk = require('chalk');
|
|
3
|
-
const ora = require('ora');
|
|
4
|
-
const fs = require('fs');
|
|
5
|
-
const path = require('path');
|
|
6
|
-
|
|
7
|
-
async function createTemplate() {
|
|
8
|
-
console.log(chalk.cyan.bold('\nš Dokio Template Generator\n'));
|
|
9
|
-
|
|
10
|
-
try {
|
|
11
|
-
// Ask user for template type
|
|
12
|
-
const answers = await inquirer.prompt([
|
|
13
|
-
{
|
|
14
|
-
type: 'list',
|
|
15
|
-
name: 'templateType',
|
|
16
|
-
message: 'What type of template do you want to create?',
|
|
17
|
-
choices: [
|
|
18
|
-
{ name: 'General (Image)', value: 'general' },
|
|
19
|
-
{ name: 'PDF', value: 'pdf' },
|
|
20
|
-
{ name: 'Email', value: 'email' },
|
|
21
|
-
{ name: 'Video', value: 'video' },
|
|
22
|
-
],
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
type: 'input',
|
|
26
|
-
name: 'templateName',
|
|
27
|
-
message: 'Template name:',
|
|
28
|
-
default: 'My Template',
|
|
29
|
-
validate: (input) => input.trim() !== '' || 'Template name cannot be empty',
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
type: 'input',
|
|
33
|
-
name: 'templateId',
|
|
34
|
-
message: 'Template ID (slug):',
|
|
35
|
-
default: (answers) => answers.templateName.toLowerCase().replace(/\s+/g, '-'),
|
|
36
|
-
validate: (input) => /^[a-z0-9-]+$/.test(input) || 'Template ID must be lowercase letters, numbers, and hyphens only',
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
type: 'input',
|
|
40
|
-
name: 'subdomain',
|
|
41
|
-
message: 'Subdomain:',
|
|
42
|
-
default: 'test',
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
type: 'input',
|
|
46
|
-
name: 'outputDir',
|
|
47
|
-
message: 'Output directory:',
|
|
48
|
-
default: (answers) => `./${answers.templateId}`,
|
|
49
|
-
},
|
|
50
|
-
]);
|
|
51
|
-
|
|
52
|
-
// Additional questions for PDF templates
|
|
53
|
-
let pdfOptions = {};
|
|
54
|
-
if (answers.templateType === 'pdf') {
|
|
55
|
-
pdfOptions = await inquirer.prompt([
|
|
56
|
-
{
|
|
57
|
-
type: 'list',
|
|
58
|
-
name: 'princeVersion',
|
|
59
|
-
message: 'Prince version:',
|
|
60
|
-
choices: ['11', '15'],
|
|
61
|
-
default: '15',
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
type: 'confirm',
|
|
65
|
-
name: 'resizable',
|
|
66
|
-
message: 'Is this a resizable template?',
|
|
67
|
-
default: false,
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
type: 'confirm',
|
|
71
|
-
name: 'dynamicPages',
|
|
72
|
-
message: 'Will this template have dynamic page count?',
|
|
73
|
-
default: false,
|
|
74
|
-
},
|
|
75
|
-
]);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// Create the template
|
|
79
|
-
const spinner = ora('Creating template files...').start();
|
|
80
|
-
|
|
81
|
-
await generateTemplateFiles({
|
|
82
|
-
...answers,
|
|
83
|
-
...pdfOptions,
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
spinner.succeed(chalk.green('Template created successfully!'));
|
|
87
|
-
|
|
88
|
-
console.log(chalk.cyan('\nš Files created:'));
|
|
89
|
-
console.log(chalk.gray(` ${answers.outputDir}/index.html`));
|
|
90
|
-
console.log(chalk.gray(` ${answers.outputDir}/style.scss.hbs`));
|
|
91
|
-
console.log(chalk.gray(` ${answers.outputDir}/data.yaml`));
|
|
92
|
-
console.log(chalk.gray(` ${answers.outputDir}/CHANGELOG.md`));
|
|
93
|
-
|
|
94
|
-
console.log(chalk.cyan('\n⨠Next steps:'));
|
|
95
|
-
console.log(chalk.gray(` cd ${answers.outputDir}`));
|
|
96
|
-
console.log(chalk.gray(' Start customizing your template files'));
|
|
97
|
-
console.log(chalk.gray(' Upload to Dokio when ready\n'));
|
|
98
|
-
|
|
99
|
-
} catch (error) {
|
|
100
|
-
if (error.isTtyError) {
|
|
101
|
-
console.error(chalk.red('Prompt couldn\'t be rendered in the current environment'));
|
|
102
|
-
} else {
|
|
103
|
-
console.error(chalk.red('Error creating template:'), error.message);
|
|
104
|
-
}
|
|
105
|
-
process.exit(1);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
async function generateTemplateFiles(config) {
|
|
110
|
-
const { templateType, outputDir } = config;
|
|
111
|
-
|
|
112
|
-
// Create output directory
|
|
113
|
-
if (!fs.existsSync(outputDir)) {
|
|
114
|
-
fs.mkdirSync(outputDir, { recursive: true });
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
// Load template files
|
|
118
|
-
const templatesDir = path.join(__dirname, '../templates', templateType);
|
|
119
|
-
|
|
120
|
-
// Generate files from templates
|
|
121
|
-
const files = ['index.html', 'style.scss.hbs', 'data.yaml', 'CHANGELOG.md'];
|
|
122
|
-
|
|
123
|
-
for (const file of files) {
|
|
124
|
-
const templatePath = path.join(templatesDir, file);
|
|
125
|
-
let content = fs.readFileSync(templatePath, 'utf8');
|
|
126
|
-
|
|
127
|
-
// Replace placeholders
|
|
128
|
-
content = replacePlaceholders(content, config);
|
|
129
|
-
|
|
130
|
-
const outputPath = path.join(outputDir, file);
|
|
131
|
-
fs.writeFileSync(outputPath, content);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
function replacePlaceholders(content, config) {
|
|
136
|
-
return content
|
|
137
|
-
.replace(/\{\{TEMPLATE_NAME\}\}/g, config.templateName)
|
|
138
|
-
.replace(/\{\{TEMPLATE_ID\}\}/g, config.templateId)
|
|
139
|
-
.replace(/\{\{SUBDOMAIN\}\}/g, config.subdomain)
|
|
140
|
-
.replace(/\{\{PRINCE_VERSION\}\}/g, config.princeVersion || '15')
|
|
141
|
-
.replace(/\{\{DATE\}\}/g, new Date().toISOString().split('T')[0]);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
module.exports = { createTemplate };
|