swpp-backends 3.1.1 → 3.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/dist/cli-index.js +0 -0
- package/dist/swpp/BasicActions.js +3 -2
- package/dist/swpp/cli.d.ts +2 -2
- package/dist/swpp/cli.js +13 -1
- package/dist/swpp/database/KeyValueDatabase.js +3 -3
- package/package.json +36 -34
package/dist/cli-index.js
CHANGED
|
File without changes
|
|
@@ -168,8 +168,9 @@ class BasicActions {
|
|
|
168
168
|
throw new untils_1.RuntimeException(untils_1.exceptionNames.fileDuplicate, `指定文件[${item.path.absPath}]已存在`);
|
|
169
169
|
}
|
|
170
170
|
}
|
|
171
|
-
await Promise.all(fileList.map(it => {
|
|
172
|
-
it.path.mkdirs()
|
|
171
|
+
await Promise.all(fileList.map(async (it) => {
|
|
172
|
+
await it.path.mkdirs();
|
|
173
|
+
await untils_1.utils.writeFile(it.path.absPath, it.content);
|
|
173
174
|
}));
|
|
174
175
|
}
|
|
175
176
|
}
|
package/dist/swpp/cli.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export interface SwppCliConfig {
|
|
2
|
-
/**
|
|
2
|
+
/** 网站根目录,可以是绝对路径也可以是相对路径(相对于 swpp.cli.json 所在目录) */
|
|
3
3
|
webRoot: string;
|
|
4
|
-
/**
|
|
4
|
+
/** 配置文件所在的相对路径(相对于 swpp.cli.json 所在目录,越靠前优先级越高) */
|
|
5
5
|
configFiles: string[] | string;
|
|
6
6
|
/** dom js 的相对路径(相对于网站根目录,`.js` 结尾) */
|
|
7
7
|
domJsPath?: string;
|
package/dist/swpp/cli.js
CHANGED
|
@@ -39,10 +39,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
39
39
|
exports.initCommand = initCommand;
|
|
40
40
|
const commander_1 = require("commander");
|
|
41
41
|
const fs_1 = __importDefault(require("fs"));
|
|
42
|
+
const path_1 = __importDefault(require("path"));
|
|
42
43
|
const index_1 = require("../index");
|
|
43
44
|
const BasicActions_1 = require("./BasicActions");
|
|
44
45
|
const untils_1 = require("./untils");
|
|
45
46
|
const HTMLParser = __importStar(require("node-html-parser"));
|
|
47
|
+
function resolveCliConfigFiles(configFiles, cliJsonPath) {
|
|
48
|
+
const cliDir = path_1.default.dirname(cliJsonPath);
|
|
49
|
+
const resolveItem = (item) => path_1.default.isAbsolute(item) ? item : path_1.default.resolve(cliDir, item);
|
|
50
|
+
return typeof configFiles === 'string' ? resolveItem(configFiles) : configFiles.map(resolveItem);
|
|
51
|
+
}
|
|
52
|
+
function resolveCliConfigDirPath(filePath, cliJsonPath) {
|
|
53
|
+
return path_1.default.isAbsolute(filePath) ? filePath : path_1.default.resolve(path_1.default.dirname(cliJsonPath), filePath);
|
|
54
|
+
}
|
|
46
55
|
async function initCommand() {
|
|
47
56
|
commander_1.program.version(index_1.swppVersion, '-v, --version', '查看当前 swpp backends 的版本号');
|
|
48
57
|
commander_1.program.addHelpText('after', ' 每行显示一条指令信息,指令后跟方括号表示可选参数,尖括号表示必填参数');
|
|
@@ -88,13 +97,16 @@ async function runBuild(cliJsonPath = './swpp.cli.json', context) {
|
|
|
88
97
|
if (!cliJsonPath.endsWith('.json')) {
|
|
89
98
|
throw new untils_1.RuntimeException(untils_1.exceptionNames.unsupportedFileType, 'CLI 配置文件仅支持 JSON 格式', { yourPath: cliJsonPath });
|
|
90
99
|
}
|
|
100
|
+
cliJsonPath = path_1.default.resolve(cliJsonPath);
|
|
91
101
|
const cliConfig = JSON.parse(await untils_1.utils.readFileUtf8(cliJsonPath));
|
|
102
|
+
cliConfig.webRoot = resolveCliConfigDirPath(cliConfig.webRoot, cliJsonPath);
|
|
103
|
+
cliConfig.configFiles = resolveCliConfigFiles(cliConfig.configFiles, cliJsonPath);
|
|
92
104
|
await checkAndInitConfig(cliConfig);
|
|
93
105
|
const actions = await BasicActions_1.BasicActions.build({
|
|
94
106
|
context,
|
|
95
107
|
publicPath: cliConfig.webRoot,
|
|
96
108
|
isServiceWorker: cliConfig.serviceWorker ?? true,
|
|
97
|
-
domJsPath: cliConfig.gen_dom ?
|
|
109
|
+
domJsPath: cliConfig.gen_dom ? (cliConfig.domJsPath ?? '/sw-dom.js') : undefined,
|
|
98
110
|
diffJsonPath: cliConfig.diffJsonPath
|
|
99
111
|
});
|
|
100
112
|
await actions.loadConfigs(Array.isArray(cliConfig.configFiles) ? cliConfig.configFiles : [cliConfig.configFiles]);
|
|
@@ -52,12 +52,12 @@ class KeyValueDatabase {
|
|
|
52
52
|
let value = item.manual ?? item.default;
|
|
53
53
|
let isNoCache = false;
|
|
54
54
|
if (SpecialConfig_1.SpecialConfig.isRuntimeSpecialConfig(value)) {
|
|
55
|
-
this.runtime.debugCallChain.push(this.namespace, key);
|
|
56
|
-
value = value.get(this.runtime, this.compilation);
|
|
57
|
-
this.runtime.debugCallChain.pop(this.namespace, key);
|
|
58
55
|
if (SpecialConfig_1.SpecialConfig.isNoCacheConfig(value)) {
|
|
59
56
|
isNoCache = true;
|
|
60
57
|
}
|
|
58
|
+
this.runtime.debugCallChain.push(this.namespace, key);
|
|
59
|
+
value = value.get(this.runtime, this.compilation);
|
|
60
|
+
this.runtime.debugCallChain.pop(this.namespace, key);
|
|
61
61
|
}
|
|
62
62
|
// 进行类型预检
|
|
63
63
|
if (!(item.default === null || item.default === undefined || value === null || value === undefined) && typeof value != typeof item.default) {
|
package/package.json
CHANGED
|
@@ -1,35 +1,37 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "swpp-backends",
|
|
3
|
-
"version": "3.1.
|
|
4
|
-
"main": "dist/index.js",
|
|
5
|
-
"typings": "dist/index.d.ts",
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
"
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
"
|
|
15
|
-
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
"
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
"
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "swpp-backends",
|
|
3
|
+
"version": "3.1.3",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
|
+
"typings": "dist/index.d.ts",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"prepublishOnly": "tsc"
|
|
8
|
+
},
|
|
9
|
+
"description": "Generate a powerful ServiceWorker for your website.",
|
|
10
|
+
"author": "kmar",
|
|
11
|
+
"license": "AGPL-3.0",
|
|
12
|
+
"files": [
|
|
13
|
+
"dist",
|
|
14
|
+
"types"
|
|
15
|
+
],
|
|
16
|
+
"bin": {
|
|
17
|
+
"swpp-cli": "dist/cli-index.js"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@types/node": "^22.9.3",
|
|
21
|
+
"typescript": "^5.7.2"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"commander": "^12.1.0",
|
|
25
|
+
"jiti": "^2.4.2",
|
|
26
|
+
"node-html-parser": "^7.0.1"
|
|
27
|
+
},
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "git+ssh://git@github.com/EmptyDreams/swpp-backends.git"
|
|
31
|
+
},
|
|
32
|
+
"homepage": "https://swpp.kmar.top/",
|
|
33
|
+
"keywords": [
|
|
34
|
+
"ServiceWorker",
|
|
35
|
+
"sw"
|
|
36
|
+
]
|
|
35
37
|
}
|