Skip to content

Commit 2cc94f6

Browse files
committed
feat: add header to generated config file indicating it should not be edited
1 parent e75bb9e commit 2cc94f6

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

frontend/src/utils/generator.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ import {
1919
useRulesetsStore,
2020
useSubscribesStore,
2121
} from '@/stores'
22-
23-
import { deepAssign, deepClone } from './others'
22+
import { deepAssign, deepClone, APP_TITLE } from '@/utils'
2423

2524
const _generateRule = (rule: IRule | IDNSRule, rule_set: IRuleSet[], inbounds: IInbound[]) => {
2625
const getInbound = (id: string) => inbounds.find((v) => v.id === id)?.tag
@@ -436,6 +435,8 @@ export const generateConfigFile = async (
436435
profile: IProfile,
437436
beforeWrite: (config: any) => Promise<any>,
438437
) => {
438+
const header = `DO NOT EDIT - Generated by ${APP_TITLE}`
439+
439440
const _config = await generateConfig(profile)
440441
const config = await beforeWrite(_config)
441442

@@ -447,5 +448,5 @@ export const generateConfigFile = async (
447448

448449
config.experimental.cache_file.path = 'cache.db'
449450

450-
await WriteFile(CoreConfigFilePath, JSON.stringify(config, null, 2))
451+
await WriteFile(CoreConfigFilePath, JSON.stringify({ $schema: header, ...config }, null, 2))
451452
}

0 commit comments

Comments
 (0)