Skip to content

Commit 0c187f4

Browse files
committed
Fix cache name consistency and update project metadata
Update default cache name from `changba-template-cache` to `cb-template-cache` across all configuration files to ensure consistency. Update package description, repository URLs, and remove "changba" keyword in package.json to reflect project rebranding. Adjust test cases and comments to match new cache name for correctness verification.
1 parent 45da27e commit 0c187f4

File tree

5 files changed

+15
-16
lines changed

5 files changed

+15
-16
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ Parameters:
192192
* data: Object, data for rendering. Object keys are automatically converted to variable names in the template
193193
* options: Object, compilation parameters.
194194
* cache: Boolean, whether to enable compilation cache, default is enabled
195-
* cacheName: String, set cache name, default value `changba-template-cache`. This value is invalid if `cbT.cachePath` is set
195+
* cacheName: String, set cache name, default value `cb-template-cache`. This value is invalid if `cbT.cachePath` is set
196196
* callback: Function, callback function executed after compilation.
197197
* Callback function parameters: err: whether there is an error; content: rendered result
198198

README_zh.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ cbT.render(`<title><%=title%></title><p><%=nickname%></p>`, { title: '标题', n
192192
* data: 对象,用于渲染的数据,对象的 key 会自动转换为模板中的变量名
193193
* options: 对象,编译参数。
194194
* cache: 布尔,是否开启编译缓存,默认开启
195-
* cacheName: 字符串,设置缓存名称,默认值 `changba-template-cache`,如果设置过 `cbT.cachePath` 则此值无效
195+
* cacheName: 字符串,设置缓存名称,默认值 `cb-template-cache`,如果设置过 `cbT.cachePath` 则此值无效
196196
* callback: 函数,回调函数,编译完成后回调。
197197
* 回调函数参数: err: 是否有错误;content: 渲染后的结果
198198

lib/layout.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class Layout {
3535
this.defaultOptions = {
3636
block: '',
3737
cache: true,
38-
cacheName: 'changba-template-cache'
38+
cacheName: 'cb-template-cache'
3939
}
4040
}
4141

@@ -110,7 +110,7 @@ class Layout {
110110
files: this.templateTimes
111111
};
112112

113-
let result = `'/* changba template engine\n${JSON.stringify(cacheInfo)}\n*/+'`;
113+
let result = `'/* cb template engine\n${JSON.stringify(cacheInfo)}\n*/+'`;
114114

115115
if (block !== '') {
116116
// Support getting block content directly

package.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "cb-template",
33
"version": "3.0.1",
4-
"description": "Changba Template Engine",
4+
"description": "A Node.js server-side template engine that supports multi-level template inheritance.",
55
"type": "module",
66
"main": "index.js",
77
"types": "index.d.ts",
@@ -23,12 +23,11 @@
2323
},
2424
"repository": {
2525
"type": "git",
26-
"url": "git+https://github.com/ChangbaFE/cbT.git"
26+
"url": "git+https://github.com/hex-ci/cbT.git"
2727
},
2828
"keywords": [
2929
"template",
3030
"template-engine",
31-
"changba",
3231
"cbT",
3332
"server-side-template",
3433
"template-inheritance",
@@ -38,9 +37,9 @@
3837
"author": "Hex",
3938
"license": "MIT",
4039
"bugs": {
41-
"url": "https://github.com/ChangbaFE/cbT/issues"
40+
"url": "https://github.com/hex-ci/cbT/issues"
4241
},
43-
"homepage": "https://github.com/ChangbaFE/cbT#readme",
42+
"homepage": "https://github.com/hex-ci/cbT#readme",
4443
"devDependencies": {
4544
"@babel/preset-env": "^7.28.0",
4645
"babel-jest": "^30.0.4",

test/layout.test.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -466,11 +466,11 @@ describe('layout.js', () => {
466466
expect(err1).toBeNull();
467467

468468
// Now manually create a cache file with wrong version
469-
const cacheDir = layout.core.cachePath || path.join(os.tmpdir(), 'changba-template-cache', require('../lib/utils').getHash(layout.core.basePath));
469+
const cacheDir = layout.core.cachePath || path.join(os.tmpdir(), 'cb-template-cache', require('../lib/utils').getHash(layout.core.basePath));
470470
const cacheFile = path.join(cacheDir, require('../lib/utils').getHash('version.html') + '.html');
471471

472472
// Create cache with wrong version
473-
const wrongCacheContent = `'/* changba template engine
473+
const wrongCacheContent = `'/* cb template engine
474474
{"version":"wrong-version","files":{}}
475475
*/+'test content`;
476476

@@ -496,12 +496,12 @@ describe('layout.js', () => {
496496
fs.writeFileSync(path.join(testDir, 'corrupt.html'), content);
497497

498498
// Create corrupted cache file
499-
const cacheDir = layout.core.cachePath || path.join(os.tmpdir(), 'changba-template-cache', require('../lib/utils').getHash(layout.core.basePath));
499+
const cacheDir = layout.core.cachePath || path.join(os.tmpdir(), 'cb-template-cache', require('../lib/utils').getHash(layout.core.basePath));
500500
const cacheFile = path.join(cacheDir, require('../lib/utils').getHash('corrupt.html') + '.html');
501501

502502
require('../lib/utils').mkdirp(cacheDir, () => {
503503
// Write corrupted JSON
504-
const corruptCache = `'/* changba template engine
504+
const corruptCache = `'/* cb template engine
505505
{invalid json}
506506
*/+'test content`;
507507

@@ -524,7 +524,7 @@ describe('layout.js', () => {
524524
fs.writeFileSync(path.join(testDir, 'readerror.html'), content);
525525

526526
// Create a cache file we can't read
527-
const cacheDir = layout.core.cachePath || path.join(os.tmpdir(), 'changba-template-cache', require('../lib/utils').getHash(layout.core.basePath));
527+
const cacheDir = layout.core.cachePath || path.join(os.tmpdir(), 'cb-template-cache', require('../lib/utils').getHash(layout.core.basePath));
528528
const cacheFile = path.join(cacheDir, require('../lib/utils').getHash('readerror.html') + '.html');
529529

530530
require('../lib/utils').mkdirp(cacheDir, () => {
@@ -1373,10 +1373,10 @@ describe('layout.js', () => {
13731373
fs.writeFileSync(path.join(testDir, 'cache-no-files.html'), content);
13741374

13751375
// Create a cache file with no files property
1376-
const cacheDir = layout.core.cachePath || path.join(os.tmpdir(), 'changba-template-cache', require('../lib/utils').getHash(layout.core.basePath));
1376+
const cacheDir = layout.core.cachePath || path.join(os.tmpdir(), 'cb-template-cache', require('../lib/utils').getHash(layout.core.basePath));
13771377
const cacheFile = path.join(cacheDir, require('../lib/utils').getHash('cache-no-files.html') + '.html');
13781378

1379-
const cacheContent = `'/* changba template engine
1379+
const cacheContent = `'/* cb template engine
13801380
{"version":"${layout.core.version}"}
13811381
*/+'test content`;
13821382

0 commit comments

Comments
 (0)