mirror of
https://git.mirrors.martin98.com/https://github.com/sub-store-org/Sub-Store.git
synced 2025-08-10 13:29:03 +08:00
revert: 回滚文件模板功能
This commit is contained in:
parent
5ecce27f4e
commit
27a14bb255
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "sub-store",
|
"name": "sub-store",
|
||||||
"version": "2.14.155",
|
"version": "2.14.157",
|
||||||
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.",
|
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.",
|
||||||
"main": "src/main.js",
|
"main": "src/main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@ -21,7 +21,6 @@
|
|||||||
"http-proxy-middleware": "^2.0.6",
|
"http-proxy-middleware": "^2.0.6",
|
||||||
"js-base64": "^3.7.2",
|
"js-base64": "^3.7.2",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
"nunjucks": "^3.2.4",
|
|
||||||
"request": "^2.88.2",
|
"request": "^2.88.2",
|
||||||
"requests": "^0.3.0",
|
"requests": "^0.3.0",
|
||||||
"semver": "^7.3.7",
|
"semver": "^7.3.7",
|
||||||
|
39
backend/pnpm-lock.yaml
generated
39
backend/pnpm-lock.yaml
generated
@ -26,9 +26,6 @@ dependencies:
|
|||||||
lodash:
|
lodash:
|
||||||
specifier: ^4.17.21
|
specifier: ^4.17.21
|
||||||
version: registry.npmmirror.com/lodash@4.17.21
|
version: registry.npmmirror.com/lodash@4.17.21
|
||||||
nunjucks:
|
|
||||||
specifier: ^3.2.4
|
|
||||||
version: registry.npmmirror.com/nunjucks@3.2.4
|
|
||||||
request:
|
request:
|
||||||
specifier: ^2.88.2
|
specifier: ^2.88.2
|
||||||
version: registry.npmmirror.com/request@2.88.2
|
version: registry.npmmirror.com/request@2.88.2
|
||||||
@ -2124,12 +2121,6 @@ packages:
|
|||||||
through: registry.npmmirror.com/through@2.3.8
|
through: registry.npmmirror.com/through@2.3.8
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
registry.npmmirror.com/a-sync-waterfall@1.0.1:
|
|
||||||
resolution: {integrity: sha512-RYTOHHdWipFUliRFMCS4X2Yn2X8M87V/OpSqWzKKOGhzqyUxzyVmhHDH9sAvG+ZuQf/TAOFsLCpMw09I1ufUnA==, registry: http://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/a-sync-waterfall/-/a-sync-waterfall-1.0.1.tgz}
|
|
||||||
name: a-sync-waterfall
|
|
||||||
version: 1.0.1
|
|
||||||
dev: false
|
|
||||||
|
|
||||||
registry.npmmirror.com/abbrev@1.1.1:
|
registry.npmmirror.com/abbrev@1.1.1:
|
||||||
resolution: {integrity: sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==, registry: http://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/abbrev/-/abbrev-1.1.1.tgz}
|
resolution: {integrity: sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==, registry: http://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/abbrev/-/abbrev-1.1.1.tgz}
|
||||||
name: abbrev
|
name: abbrev
|
||||||
@ -2468,12 +2459,6 @@ packages:
|
|||||||
is-string: registry.npmmirror.com/is-string@1.0.7
|
is-string: registry.npmmirror.com/is-string@1.0.7
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
registry.npmmirror.com/asap@2.0.6:
|
|
||||||
resolution: {integrity: sha512-BSHWgDSAiKs50o2Re8ppvp3seVHXSRM44cdSsT9FfNEUUZLOGWVCsiWaRPWM1Znn+mqZ1OfVZ3z3DWEzSp7hRA==, registry: http://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/asap/-/asap-2.0.6.tgz}
|
|
||||||
name: asap
|
|
||||||
version: 2.0.6
|
|
||||||
dev: false
|
|
||||||
|
|
||||||
registry.npmmirror.com/asn1.js@5.4.1:
|
registry.npmmirror.com/asn1.js@5.4.1:
|
||||||
resolution: {integrity: sha512-+I//4cYPccV8LdmBLiX8CYvf9Sp3vQsrqu2QNXRcrbiWvcx/UdlFiqUJJzxRQxgsZmvhXhn4cSKeSmoFjVdupA==, registry: http://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/asn1.js/-/asn1.js-5.4.1.tgz}
|
resolution: {integrity: sha512-+I//4cYPccV8LdmBLiX8CYvf9Sp3vQsrqu2QNXRcrbiWvcx/UdlFiqUJJzxRQxgsZmvhXhn4cSKeSmoFjVdupA==, registry: http://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/asn1.js/-/asn1.js-5.4.1.tgz}
|
||||||
name: asn1.js
|
name: asn1.js
|
||||||
@ -3481,13 +3466,6 @@ packages:
|
|||||||
engines: {node: '>= 6'}
|
engines: {node: '>= 6'}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
registry.npmmirror.com/commander@5.1.0:
|
|
||||||
resolution: {integrity: sha512-P0CysNDQ7rtVw4QIQtm+MRxV66vKFSvlsQvGYXZWR3qFU0jlMKHZZZgw8e+8DSah4UDKMqnknRDQz+xuQXQ/Zg==, registry: http://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/commander/-/commander-5.1.0.tgz}
|
|
||||||
name: commander
|
|
||||||
version: 5.1.0
|
|
||||||
engines: {node: '>= 6'}
|
|
||||||
dev: false
|
|
||||||
|
|
||||||
registry.npmmirror.com/commander@9.3.0:
|
registry.npmmirror.com/commander@9.3.0:
|
||||||
resolution: {integrity: sha512-hv95iU5uXPbK83mjrJKuZyFM/LBAoCV/XhVGkS5Je6tl7sxr6A0ITMw5WoRV46/UaJ46Nllm3Xt7IaJhXTIkzw==, registry: http://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/commander/-/commander-9.3.0.tgz}
|
resolution: {integrity: sha512-hv95iU5uXPbK83mjrJKuZyFM/LBAoCV/XhVGkS5Je6tl7sxr6A0ITMw5WoRV46/UaJ46Nllm3Xt7IaJhXTIkzw==, registry: http://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/commander/-/commander-9.3.0.tgz}
|
||||||
name: commander
|
name: commander
|
||||||
@ -7396,23 +7374,6 @@ packages:
|
|||||||
engines: {node: '>=0.10.0'}
|
engines: {node: '>=0.10.0'}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
registry.npmmirror.com/nunjucks@3.2.4:
|
|
||||||
resolution: {integrity: sha512-26XRV6BhkgK0VOxfbU5cQI+ICFUtMLixv1noZn1tGU38kQH5A5nmmbk/O45xdyBhD1esk47nKrY0mvQpZIhRjQ==, registry: http://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/nunjucks/-/nunjucks-3.2.4.tgz}
|
|
||||||
name: nunjucks
|
|
||||||
version: 3.2.4
|
|
||||||
engines: {node: '>= 6.9.0'}
|
|
||||||
hasBin: true
|
|
||||||
peerDependencies:
|
|
||||||
chokidar: ^3.3.0
|
|
||||||
peerDependenciesMeta:
|
|
||||||
chokidar:
|
|
||||||
optional: true
|
|
||||||
dependencies:
|
|
||||||
a-sync-waterfall: registry.npmmirror.com/a-sync-waterfall@1.0.1
|
|
||||||
asap: registry.npmmirror.com/asap@2.0.6
|
|
||||||
commander: registry.npmmirror.com/commander@5.1.0
|
|
||||||
dev: false
|
|
||||||
|
|
||||||
registry.npmmirror.com/oauth-sign@0.9.0:
|
registry.npmmirror.com/oauth-sign@0.9.0:
|
||||||
resolution: {integrity: sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==, registry: http://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/oauth-sign/-/oauth-sign-0.9.0.tgz}
|
resolution: {integrity: sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==, registry: http://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/oauth-sign/-/oauth-sign-0.9.0.tgz}
|
||||||
name: oauth-sign
|
name: oauth-sign
|
||||||
|
@ -3,7 +3,6 @@ import { ProxyUtils } from '@/core/proxy-utils';
|
|||||||
import { findByName } from '@/utils/database';
|
import { findByName } from '@/utils/database';
|
||||||
import { success, failed } from './response';
|
import { success, failed } from './response';
|
||||||
import download from '@/utils/download';
|
import download from '@/utils/download';
|
||||||
import { render } from '@/utils/tpl';
|
|
||||||
import { SUBS_KEY } from '@/constants';
|
import { SUBS_KEY } from '@/constants';
|
||||||
import $ from '@/core/app';
|
import $ from '@/core/app';
|
||||||
|
|
||||||
@ -64,10 +63,6 @@ async function previewFile(req, res) {
|
|||||||
.filter((i) => i != null && i !== '')
|
.filter((i) => i != null && i !== '')
|
||||||
.join('\n');
|
.join('\n');
|
||||||
|
|
||||||
if (file.isTpl) {
|
|
||||||
filesContent = await render(filesContent);
|
|
||||||
}
|
|
||||||
|
|
||||||
// apply processors
|
// apply processors
|
||||||
const processed =
|
const processed =
|
||||||
Array.isArray(file.process) && file.process.length > 0
|
Array.isArray(file.process) && file.process.length > 0
|
||||||
|
@ -13,7 +13,6 @@ import download from '@/utils/download';
|
|||||||
import { ProxyUtils } from '@/core/proxy-utils';
|
import { ProxyUtils } from '@/core/proxy-utils';
|
||||||
import { RuleUtils } from '@/core/rule-utils';
|
import { RuleUtils } from '@/core/rule-utils';
|
||||||
import { syncToGist } from '@/restful/artifacts';
|
import { syncToGist } from '@/restful/artifacts';
|
||||||
import { render } from '@/utils/tpl';
|
|
||||||
|
|
||||||
export default function register($app) {
|
export default function register($app) {
|
||||||
// Initialization
|
// Initialization
|
||||||
@ -426,9 +425,6 @@ async function produceArtifact({
|
|||||||
.filter((i) => i != null && i !== '')
|
.filter((i) => i != null && i !== '')
|
||||||
.join('\n');
|
.join('\n');
|
||||||
|
|
||||||
if (file.isTpl) {
|
|
||||||
filesContent = await render(filesContent);
|
|
||||||
}
|
|
||||||
// apply processors
|
// apply processors
|
||||||
const processed =
|
const processed =
|
||||||
Array.isArray(file.process) && file.process.length > 0
|
Array.isArray(file.process) && file.process.length > 0
|
||||||
|
@ -1,210 +0,0 @@
|
|||||||
import nunjucks from 'nunjucks';
|
|
||||||
import { ProxyUtils } from '@/core/proxy-utils';
|
|
||||||
import { produceArtifact } from '@/restful/sync';
|
|
||||||
import lodash from 'lodash';
|
|
||||||
import $ from '@/core/app';
|
|
||||||
import scriptResourceCache from '@/utils/script-resource-cache';
|
|
||||||
import { getFlowHeaders, parseFlowHeaders, flowTransfer } from '@/utils/flow';
|
|
||||||
const flowUtils = { getFlowHeaders, parseFlowHeaders, flowTransfer };
|
|
||||||
const n = nunjucks.configure({ autoescape: false });
|
|
||||||
|
|
||||||
n.addFilter(
|
|
||||||
'produceArtifact',
|
|
||||||
(...args) => {
|
|
||||||
const callback = args.pop();
|
|
||||||
const name = args[0];
|
|
||||||
const type = args[1];
|
|
||||||
const platform = args[2];
|
|
||||||
const produceType = args[3];
|
|
||||||
const nameRegex = args[4];
|
|
||||||
const nameRegexFlags = args[5];
|
|
||||||
produceArtifact({
|
|
||||||
type,
|
|
||||||
name,
|
|
||||||
platform,
|
|
||||||
produceType,
|
|
||||||
})
|
|
||||||
.then((artifact) => {
|
|
||||||
callback(
|
|
||||||
null,
|
|
||||||
artifact.filter(({ tag }) =>
|
|
||||||
nameRegex
|
|
||||||
? new RegExp(nameRegex, nameRegexFlags).test(tag)
|
|
||||||
: true,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
})
|
|
||||||
.catch((e) => {
|
|
||||||
$.error(`produceArtifact filter error: ${e.message ?? e}`);
|
|
||||||
callback(e);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
true,
|
|
||||||
);
|
|
||||||
n.addFilter(
|
|
||||||
'subNode',
|
|
||||||
(...args) => {
|
|
||||||
const callback = args.pop();
|
|
||||||
const name = args[0];
|
|
||||||
const nameRegex = args[1];
|
|
||||||
const nameRegexFlags = args[2];
|
|
||||||
produceArtifact({
|
|
||||||
type: 'subscription',
|
|
||||||
name,
|
|
||||||
platform: 'sing-box',
|
|
||||||
produceType: 'internal',
|
|
||||||
})
|
|
||||||
.then((artifact) => {
|
|
||||||
callback(
|
|
||||||
null,
|
|
||||||
JSON.stringify(
|
|
||||||
artifact.filter(({ tag }) =>
|
|
||||||
nameRegex
|
|
||||||
? new RegExp(nameRegex, nameRegexFlags).test(
|
|
||||||
tag,
|
|
||||||
)
|
|
||||||
: true,
|
|
||||||
),
|
|
||||||
).replace(/(^\[|\]$)/g, ''),
|
|
||||||
);
|
|
||||||
})
|
|
||||||
.catch((e) => {
|
|
||||||
$.error(`subNode filter error: ${e.message ?? e}`);
|
|
||||||
callback(e);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
true,
|
|
||||||
);
|
|
||||||
n.addFilter(
|
|
||||||
'colNode',
|
|
||||||
(...args) => {
|
|
||||||
const callback = args.pop();
|
|
||||||
const name = args[0];
|
|
||||||
const nameRegex = args[1];
|
|
||||||
const nameRegexFlags = args[2];
|
|
||||||
produceArtifact({
|
|
||||||
type: 'collection',
|
|
||||||
name,
|
|
||||||
platform: 'sing-box',
|
|
||||||
produceType: 'internal',
|
|
||||||
})
|
|
||||||
.then((artifact) => {
|
|
||||||
callback(
|
|
||||||
null,
|
|
||||||
JSON.stringify(
|
|
||||||
artifact.filter(({ tag }) =>
|
|
||||||
nameRegex
|
|
||||||
? new RegExp(nameRegex, nameRegexFlags).test(
|
|
||||||
tag,
|
|
||||||
)
|
|
||||||
: true,
|
|
||||||
),
|
|
||||||
).replace(/(^\[|\]$)/g, ''),
|
|
||||||
);
|
|
||||||
})
|
|
||||||
.catch((e) => {
|
|
||||||
$.error(`colNode filter error: ${e.message ?? e}`);
|
|
||||||
callback(e);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
true,
|
|
||||||
);
|
|
||||||
n.addFilter(
|
|
||||||
'sub',
|
|
||||||
(...args) => {
|
|
||||||
const callback = args.pop();
|
|
||||||
const name = args[0];
|
|
||||||
const nameRegex = args[1];
|
|
||||||
const nameRegexFlags = args[2];
|
|
||||||
produceArtifact({
|
|
||||||
type: 'subscription',
|
|
||||||
name,
|
|
||||||
platform: 'sing-box',
|
|
||||||
produceType: 'internal',
|
|
||||||
})
|
|
||||||
.then((artifact) => {
|
|
||||||
callback(
|
|
||||||
null,
|
|
||||||
JSON.stringify(
|
|
||||||
artifact
|
|
||||||
.filter(({ tag }) =>
|
|
||||||
nameRegex
|
|
||||||
? new RegExp(
|
|
||||||
nameRegex,
|
|
||||||
nameRegexFlags,
|
|
||||||
).test(tag)
|
|
||||||
: true,
|
|
||||||
)
|
|
||||||
.map((p) => p.tag),
|
|
||||||
).replace(/(^\[|\]$)/g, ''),
|
|
||||||
);
|
|
||||||
})
|
|
||||||
.catch((e) => {
|
|
||||||
$.error(`sub filter error: ${e.message ?? e}`);
|
|
||||||
callback(e);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
true,
|
|
||||||
);
|
|
||||||
n.addFilter(
|
|
||||||
'col',
|
|
||||||
(...args) => {
|
|
||||||
const callback = args.pop();
|
|
||||||
const name = args[0];
|
|
||||||
const nameRegex = args[1];
|
|
||||||
const nameRegexFlags = args[2];
|
|
||||||
produceArtifact({
|
|
||||||
type: 'collection',
|
|
||||||
name,
|
|
||||||
platform: 'sing-box',
|
|
||||||
produceType: 'internal',
|
|
||||||
})
|
|
||||||
.then((artifact) => {
|
|
||||||
callback(
|
|
||||||
null,
|
|
||||||
JSON.stringify(
|
|
||||||
artifact
|
|
||||||
.filter(({ tag }) =>
|
|
||||||
nameRegex
|
|
||||||
? new RegExp(
|
|
||||||
nameRegex,
|
|
||||||
nameRegexFlags,
|
|
||||||
).test(tag)
|
|
||||||
: true,
|
|
||||||
)
|
|
||||||
.map((p) => p.tag),
|
|
||||||
).replace(/(^\[|\]$)/g, ''),
|
|
||||||
);
|
|
||||||
})
|
|
||||||
.catch((e) => {
|
|
||||||
$.error(`col filter error: ${e.message ?? e}`);
|
|
||||||
callback(e);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
true,
|
|
||||||
);
|
|
||||||
|
|
||||||
export const render = async (tpl = '', data = {}) => {
|
|
||||||
return new Promise((resolve) => {
|
|
||||||
n.renderString(
|
|
||||||
tpl,
|
|
||||||
{
|
|
||||||
$substore: $,
|
|
||||||
lodash: lodash,
|
|
||||||
ProxyUtils: ProxyUtils,
|
|
||||||
scriptResourceCache: scriptResourceCache,
|
|
||||||
flowUtils: flowUtils,
|
|
||||||
// produceArtifact: produceArtifact,
|
|
||||||
...data,
|
|
||||||
},
|
|
||||||
(e, result) => {
|
|
||||||
if (e) {
|
|
||||||
$.error(`rendering error: ${e.message ?? e}`);
|
|
||||||
resolve('');
|
|
||||||
} else {
|
|
||||||
resolve(result);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
);
|
|
||||||
});
|
|
||||||
};
|
|
Loading…
x
Reference in New Issue
Block a user