@hashtagcms/themes 1.0.0 → 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/README.md +15 -0
- package/bin/cli.js +89 -0
- package/package.json +9 -4
package/README.md
CHANGED
|
@@ -43,6 +43,21 @@ import '@hashtagcms/themes/src/themes/basic/js/app';
|
|
|
43
43
|
<script src="node_modules/@hashtagcms/themes/dist/themes/basic/app.js"></script>
|
|
44
44
|
```
|
|
45
45
|
|
|
46
|
+
### 💻 CLI Usage
|
|
47
|
+
|
|
48
|
+
You can interactive copy assets (fonts, images, vendor files) from a theme to your project using the CLI.
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
# Run the interactive setup
|
|
52
|
+
npx @hashtagcms/themes init
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
The CLI will ask you:
|
|
56
|
+
1. Which theme you want to install
|
|
57
|
+
2. Where to copy the assets (default: `./resources/assets/fe`)
|
|
58
|
+
|
|
59
|
+
The assets will be copied to `<destination>/<theme-name>/`.
|
|
60
|
+
|
|
46
61
|
## 🎨 Available Themes
|
|
47
62
|
|
|
48
63
|
### Basic Theme
|
package/bin/cli.js
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const inquirer = require('inquirer');
|
|
4
|
+
const fs = require('fs-extra');
|
|
5
|
+
const path = require('path');
|
|
6
|
+
const chalk = require('chalk');
|
|
7
|
+
|
|
8
|
+
async function run() {
|
|
9
|
+
try {
|
|
10
|
+
// Resolve the source path (the themes folder inside this package)
|
|
11
|
+
const sourcePath = path.resolve(__dirname, '../src/themes');
|
|
12
|
+
|
|
13
|
+
if (!fs.existsSync(sourcePath)) {
|
|
14
|
+
console.error(chalk.red(`Error: Source themes directory not found at ${sourcePath}`));
|
|
15
|
+
process.exit(1);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Get all available themes
|
|
19
|
+
const themes = await fs.readdir(sourcePath);
|
|
20
|
+
const validThemes = [];
|
|
21
|
+
|
|
22
|
+
for (const theme of themes) {
|
|
23
|
+
if ((await fs.stat(path.join(sourcePath, theme))).isDirectory()) {
|
|
24
|
+
validThemes.push(theme);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (validThemes.length === 0) {
|
|
29
|
+
console.error(chalk.red('Error: No themes found in the package.'));
|
|
30
|
+
process.exit(1);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const questions = [
|
|
34
|
+
{
|
|
35
|
+
type: 'list',
|
|
36
|
+
name: 'theme',
|
|
37
|
+
message: 'Which theme would you like to install?',
|
|
38
|
+
choices: validThemes,
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
type: 'input',
|
|
42
|
+
name: 'destination',
|
|
43
|
+
message: 'Where would you like to copy the assets?',
|
|
44
|
+
default: './resources/assets/fe',
|
|
45
|
+
},
|
|
46
|
+
];
|
|
47
|
+
|
|
48
|
+
const answers = await inquirer.prompt(questions);
|
|
49
|
+
|
|
50
|
+
// Resolve the destination path based on the user's input (relative to their project root)
|
|
51
|
+
const destinationPath = path.resolve(process.cwd(), answers.destination);
|
|
52
|
+
|
|
53
|
+
// Selected theme path
|
|
54
|
+
const selectedThemePath = path.join(sourcePath, answers.theme);
|
|
55
|
+
|
|
56
|
+
console.log(chalk.blue(`Copying assets for theme '${answers.theme}'...`));
|
|
57
|
+
|
|
58
|
+
// Copy only specific asset folders
|
|
59
|
+
const assets = ['img', 'fonts', 'images', 'vendor'];
|
|
60
|
+
let copiedCount = 0;
|
|
61
|
+
|
|
62
|
+
for (const asset of assets) {
|
|
63
|
+
const assetSrc = path.join(selectedThemePath, asset);
|
|
64
|
+
// Destination structure: destination/themeName/assetFolder
|
|
65
|
+
// Example: ./resources/assets/fe/basic/img
|
|
66
|
+
const assetDest = path.join(destinationPath, answers.theme, asset);
|
|
67
|
+
|
|
68
|
+
if (await fs.pathExists(assetSrc)) {
|
|
69
|
+
// Copy the files recursively
|
|
70
|
+
await fs.copy(assetSrc, assetDest);
|
|
71
|
+
console.log(chalk.gray(`✓ Copied ${answers.theme}/${asset}`));
|
|
72
|
+
copiedCount++;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (copiedCount === 0) {
|
|
77
|
+
console.warn(chalk.yellow(`No assets (${assets.join(', ')}) were found to copy for theme '${answers.theme}'.`));
|
|
78
|
+
} else {
|
|
79
|
+
// Log a success message in green
|
|
80
|
+
console.log(chalk.green(`\nSuccess! Assets for '${answers.theme}' copied to ${answers.destination}/${answers.theme}`));
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
} catch (error) {
|
|
84
|
+
console.error(chalk.red('Error copying assets:'), error);
|
|
85
|
+
process.exit(1);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
run();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hashtagcms/themes",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"author": {
|
|
5
5
|
"name": "Marghoob Suleman",
|
|
6
6
|
"email": "marghoobsuleman@gmail.com",
|
|
@@ -16,8 +16,10 @@
|
|
|
16
16
|
},
|
|
17
17
|
"homepage": "https://github.com/marghoobsuleman/cms-frontend-kit#readme",
|
|
18
18
|
"main": "src/core/js/index.js",
|
|
19
|
+
"bin": "./bin/cli.js",
|
|
19
20
|
"files": [
|
|
20
|
-
"src"
|
|
21
|
+
"src",
|
|
22
|
+
"bin"
|
|
21
23
|
],
|
|
22
24
|
"scripts": {
|
|
23
25
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
@@ -30,9 +32,9 @@
|
|
|
30
32
|
"@babel/core": "^7.23.0",
|
|
31
33
|
"@babel/preset-env": "^7.23.0",
|
|
32
34
|
"babel-loader": "^9.1.0",
|
|
35
|
+
"copy-webpack-plugin": "^11.0.0",
|
|
33
36
|
"css-loader": "^6.8.0",
|
|
34
37
|
"mini-css-extract-plugin": "^2.7.0",
|
|
35
|
-
"copy-webpack-plugin": "^11.0.0",
|
|
36
38
|
"sass": "^1.69.0",
|
|
37
39
|
"sass-loader": "^13.3.0",
|
|
38
40
|
"webpack": "^5.89.0",
|
|
@@ -40,6 +42,9 @@
|
|
|
40
42
|
},
|
|
41
43
|
"dependencies": {
|
|
42
44
|
"axios": "^1.8.0",
|
|
43
|
-
"bootstrap": "^5.3.3"
|
|
45
|
+
"bootstrap": "^5.3.3",
|
|
46
|
+
"chalk": "^4.1.2",
|
|
47
|
+
"fs-extra": "^11.3.3",
|
|
48
|
+
"inquirer": "^8.2.7"
|
|
44
49
|
}
|
|
45
50
|
}
|