kempo-css 1.0.2 → 1.0.4
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/.github/workflows/publish-npm.yml +41 -0
- package/build.js +100 -100
- package/index.html +1327 -1327
- package/kempo-hljs.css +124 -124
- package/kempo.css +1020 -1020
- package/package.json +5 -1
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
|
|
2
|
+
name: Publish Package to npmjs
|
|
3
|
+
|
|
4
|
+
on:
|
|
5
|
+
push:
|
|
6
|
+
branches:
|
|
7
|
+
- main
|
|
8
|
+
workflow_dispatch:
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
publish:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
permissions:
|
|
14
|
+
contents: read
|
|
15
|
+
id-token: write # enables npm provenance
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v4
|
|
18
|
+
|
|
19
|
+
# Setup Node and create an .npmrc that uses the token from NODE_AUTH_TOKEN
|
|
20
|
+
- uses: actions/setup-node@v4
|
|
21
|
+
with:
|
|
22
|
+
node-version: '20.x'
|
|
23
|
+
registry-url: 'https://registry.npmjs.org'
|
|
24
|
+
|
|
25
|
+
- run: npm ci
|
|
26
|
+
|
|
27
|
+
# Auto-increment patch version, commit, and push
|
|
28
|
+
- name: Bump patch version
|
|
29
|
+
run: |
|
|
30
|
+
git config --global user.name "github-actions"
|
|
31
|
+
git config --global user.email "github-actions@github.com"
|
|
32
|
+
npm version patch --no-git-tag-version
|
|
33
|
+
git add package.json package-lock.json || true
|
|
34
|
+
git commit -m "ci: bump patch version [skip ci]" || echo "No changes to commit"
|
|
35
|
+
git push origin HEAD:main || echo "No changes to push"
|
|
36
|
+
|
|
37
|
+
# If your package is public and scoped (e.g., @scope/name), keep --access public.
|
|
38
|
+
# For unscoped public packages, you can omit --access.
|
|
39
|
+
- run: npm publish --provenance --access public
|
|
40
|
+
env:
|
|
41
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
package/build.js
CHANGED
|
@@ -1,101 +1,101 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const { execSync } = require('child_process');
|
|
4
|
-
const fs = require('fs');
|
|
5
|
-
const path = require('path');
|
|
6
|
-
|
|
7
|
-
// Check for watch flag
|
|
8
|
-
const isWatchMode = process.argv.includes('--watch');
|
|
9
|
-
|
|
10
|
-
if (isWatchMode) {
|
|
11
|
-
console.log('Watch mode enabled - monitoring CSS files for changes...\n');
|
|
12
|
-
} else {
|
|
13
|
-
console.log('Building Kempo CSS...\n');
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
// Define input and output files
|
|
17
|
-
const inputFiles = [
|
|
18
|
-
'kempo.css',
|
|
19
|
-
'kempo-hljs.css'
|
|
20
|
-
];
|
|
21
|
-
|
|
22
|
-
const outputDir = 'dist';
|
|
23
|
-
const outputFiles = [
|
|
24
|
-
'kempo.min.css',
|
|
25
|
-
'kempo-hljs.min.css'
|
|
26
|
-
];
|
|
27
|
-
|
|
28
|
-
// Create dist directory if it doesn't exist
|
|
29
|
-
if (!fs.existsSync(outputDir)) {
|
|
30
|
-
fs.mkdirSync(outputDir);
|
|
31
|
-
console.log(`Created ${outputDir}/ directory`);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// Minify each CSS file
|
|
35
|
-
inputFiles.forEach((inputFile, index) => {
|
|
36
|
-
const outputFile = path.join(outputDir, outputFiles[index]);
|
|
37
|
-
|
|
38
|
-
try {
|
|
39
|
-
// Check if input file exists
|
|
40
|
-
if (!fs.existsSync(inputFile)) {
|
|
41
|
-
console.log(`Skipping ${inputFile} (file not found)`);
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// Get file size before minification
|
|
46
|
-
const originalSize = fs.statSync(inputFile).size;
|
|
47
|
-
|
|
48
|
-
// Minify the CSS using clean-css-cli
|
|
49
|
-
console.log(`Minifying ${inputFile}...`);
|
|
50
|
-
execSync(`npx cleancss -o ${outputFile} ${inputFile}`, { stdio: 'inherit' });
|
|
51
|
-
|
|
52
|
-
// Get file size after minification
|
|
53
|
-
const minifiedSize = fs.statSync(outputFile).size;
|
|
54
|
-
const savings = ((originalSize - minifiedSize) / originalSize * 100).toFixed(1);
|
|
55
|
-
|
|
56
|
-
console.log(`${inputFile} → ${outputFile}`);
|
|
57
|
-
console.log(` Original: ${(originalSize / 1024).toFixed(1)}KB`);
|
|
58
|
-
console.log(` Minified: ${(minifiedSize / 1024).toFixed(1)}KB`);
|
|
59
|
-
console.log(` Savings: ${savings}%\n`);
|
|
60
|
-
} catch (error) {
|
|
61
|
-
console.error(`Error minifying ${inputFile}:`, error.message);
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
console.log('Build complete!');
|
|
66
|
-
console.log(`Minified files are in the ${outputDir}/ directory`);
|
|
67
|
-
|
|
68
|
-
// Watch mode functionality
|
|
69
|
-
if (isWatchMode) {
|
|
70
|
-
console.log('Watching for changes... (Press Ctrl+C to stop)\n');
|
|
71
|
-
|
|
72
|
-
inputFiles.forEach(inputFile => {
|
|
73
|
-
if (fs.existsSync(inputFile)) {
|
|
74
|
-
fs.watchFile(inputFile, { interval: 1000 }, (curr, prev) => {
|
|
75
|
-
if (curr.mtime !== prev.mtime) {
|
|
76
|
-
console.log(`\n${inputFile} changed, rebuilding...`);
|
|
77
|
-
|
|
78
|
-
// Find the corresponding output file
|
|
79
|
-
const index = inputFiles.indexOf(inputFile);
|
|
80
|
-
const outputFile = path.join(outputDir, outputFiles[index]);
|
|
81
|
-
try {
|
|
82
|
-
const originalSize = fs.statSync(inputFile).size;
|
|
83
|
-
console.log(`Minifying ${inputFile}...`);
|
|
84
|
-
execSync(`npx cleancss -o ${outputFile} ${inputFile}`, { stdio: 'inherit' });
|
|
85
|
-
|
|
86
|
-
const minifiedSize = fs.statSync(outputFile).size;
|
|
87
|
-
const savings = ((originalSize - minifiedSize) / originalSize * 100).toFixed(1);
|
|
88
|
-
|
|
89
|
-
console.log(`${inputFile} → ${outputFile}`);
|
|
90
|
-
console.log(` Original: ${(originalSize / 1024).toFixed(1)}KB`);
|
|
91
|
-
console.log(` Minified: ${(minifiedSize / 1024).toFixed(1)}KB`);
|
|
92
|
-
console.log(` Savings: ${savings}%`);
|
|
93
|
-
console.log('\nWatching for changes...');
|
|
94
|
-
} catch (error) {
|
|
95
|
-
console.error(`Error minifying ${inputFile}:`, error.message);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
});
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { execSync } = require('child_process');
|
|
4
|
+
const fs = require('fs');
|
|
5
|
+
const path = require('path');
|
|
6
|
+
|
|
7
|
+
// Check for watch flag
|
|
8
|
+
const isWatchMode = process.argv.includes('--watch');
|
|
9
|
+
|
|
10
|
+
if (isWatchMode) {
|
|
11
|
+
console.log('Watch mode enabled - monitoring CSS files for changes...\n');
|
|
12
|
+
} else {
|
|
13
|
+
console.log('Building Kempo CSS...\n');
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// Define input and output files
|
|
17
|
+
const inputFiles = [
|
|
18
|
+
'kempo.css',
|
|
19
|
+
'kempo-hljs.css'
|
|
20
|
+
];
|
|
21
|
+
|
|
22
|
+
const outputDir = 'dist';
|
|
23
|
+
const outputFiles = [
|
|
24
|
+
'kempo.min.css',
|
|
25
|
+
'kempo-hljs.min.css'
|
|
26
|
+
];
|
|
27
|
+
|
|
28
|
+
// Create dist directory if it doesn't exist
|
|
29
|
+
if (!fs.existsSync(outputDir)) {
|
|
30
|
+
fs.mkdirSync(outputDir);
|
|
31
|
+
console.log(`Created ${outputDir}/ directory`);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Minify each CSS file
|
|
35
|
+
inputFiles.forEach((inputFile, index) => {
|
|
36
|
+
const outputFile = path.join(outputDir, outputFiles[index]);
|
|
37
|
+
|
|
38
|
+
try {
|
|
39
|
+
// Check if input file exists
|
|
40
|
+
if (!fs.existsSync(inputFile)) {
|
|
41
|
+
console.log(`Skipping ${inputFile} (file not found)`);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Get file size before minification
|
|
46
|
+
const originalSize = fs.statSync(inputFile).size;
|
|
47
|
+
|
|
48
|
+
// Minify the CSS using clean-css-cli
|
|
49
|
+
console.log(`Minifying ${inputFile}...`);
|
|
50
|
+
execSync(`npx cleancss -o ${outputFile} ${inputFile}`, { stdio: 'inherit' });
|
|
51
|
+
|
|
52
|
+
// Get file size after minification
|
|
53
|
+
const minifiedSize = fs.statSync(outputFile).size;
|
|
54
|
+
const savings = ((originalSize - minifiedSize) / originalSize * 100).toFixed(1);
|
|
55
|
+
|
|
56
|
+
console.log(`${inputFile} → ${outputFile}`);
|
|
57
|
+
console.log(` Original: ${(originalSize / 1024).toFixed(1)}KB`);
|
|
58
|
+
console.log(` Minified: ${(minifiedSize / 1024).toFixed(1)}KB`);
|
|
59
|
+
console.log(` Savings: ${savings}%\n`);
|
|
60
|
+
} catch (error) {
|
|
61
|
+
console.error(`Error minifying ${inputFile}:`, error.message);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
console.log('Build complete!');
|
|
66
|
+
console.log(`Minified files are in the ${outputDir}/ directory`);
|
|
67
|
+
|
|
68
|
+
// Watch mode functionality
|
|
69
|
+
if (isWatchMode) {
|
|
70
|
+
console.log('Watching for changes... (Press Ctrl+C to stop)\n');
|
|
71
|
+
|
|
72
|
+
inputFiles.forEach(inputFile => {
|
|
73
|
+
if (fs.existsSync(inputFile)) {
|
|
74
|
+
fs.watchFile(inputFile, { interval: 1000 }, (curr, prev) => {
|
|
75
|
+
if (curr.mtime !== prev.mtime) {
|
|
76
|
+
console.log(`\n${inputFile} changed, rebuilding...`);
|
|
77
|
+
|
|
78
|
+
// Find the corresponding output file
|
|
79
|
+
const index = inputFiles.indexOf(inputFile);
|
|
80
|
+
const outputFile = path.join(outputDir, outputFiles[index]);
|
|
81
|
+
try {
|
|
82
|
+
const originalSize = fs.statSync(inputFile).size;
|
|
83
|
+
console.log(`Minifying ${inputFile}...`);
|
|
84
|
+
execSync(`npx cleancss -o ${outputFile} ${inputFile}`, { stdio: 'inherit' });
|
|
85
|
+
|
|
86
|
+
const minifiedSize = fs.statSync(outputFile).size;
|
|
87
|
+
const savings = ((originalSize - minifiedSize) / originalSize * 100).toFixed(1);
|
|
88
|
+
|
|
89
|
+
console.log(`${inputFile} → ${outputFile}`);
|
|
90
|
+
console.log(` Original: ${(originalSize / 1024).toFixed(1)}KB`);
|
|
91
|
+
console.log(` Minified: ${(minifiedSize / 1024).toFixed(1)}KB`);
|
|
92
|
+
console.log(` Savings: ${savings}%`);
|
|
93
|
+
console.log('\nWatching for changes...');
|
|
94
|
+
} catch (error) {
|
|
95
|
+
console.error(`Error minifying ${inputFile}:`, error.message);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
101
|
}
|