|
@@ -18,6 +18,10 @@ interface InjectOptions {
|
|
}
|
|
}
|
|
type InjectionType = 'conf' | 'template' | 'all'
|
|
type InjectionType = 'conf' | 'template' | 'all'
|
|
|
|
|
|
|
|
+interface UnknownObject {
|
|
|
|
+ [index: string]: any
|
|
|
|
+}
|
|
|
|
+
|
|
const injectConfFile = (
|
|
const injectConfFile = (
|
|
injectPath: string,
|
|
injectPath: string,
|
|
{ force, logging }: InjectOptions,
|
|
{ force, logging }: InjectOptions,
|
|
@@ -29,27 +33,22 @@ const injectConfFile = (
|
|
Run \`tauri init --force conf\` to overwrite.`)
|
|
Run \`tauri init --force conf\` to overwrite.`)
|
|
if (!force) return false
|
|
if (!force) return false
|
|
} else {
|
|
} else {
|
|
- try {
|
|
|
|
- removeSync(path)
|
|
|
|
- const finalConf = merge(defaultConfig as any, customConfig as any) as {
|
|
|
|
- [index: string]: any
|
|
|
|
|
|
+ removeSync(path)
|
|
|
|
+ Object.keys(defaultConfig).forEach(key => {
|
|
|
|
+ // Options marked `null` should be removed
|
|
|
|
+ /* eslint-disable security/detect-object-injection */
|
|
|
|
+ if ((customConfig as UnknownObject)[key] === null) {
|
|
|
|
+ // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
|
|
|
+ delete (defaultConfig as UnknownObject)[key]
|
|
|
|
+ // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
|
|
|
+ delete (customConfig as UnknownObject)[key]
|
|
}
|
|
}
|
|
- Object.keys(finalConf).forEach(key => {
|
|
|
|
- // Options marked `null` should be removed
|
|
|
|
- /* eslint-disable security/detect-object-injection */
|
|
|
|
- if (finalConf[key] === null) {
|
|
|
|
- // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
|
|
|
- delete finalConf[key]
|
|
|
|
- }
|
|
|
|
- /* eslint-enable security/detect-object-injection */
|
|
|
|
- })
|
|
|
|
- writeFileSync(path, JSON.stringify(finalConf, undefined, 2))
|
|
|
|
- } catch (e) {
|
|
|
|
- if (logging) console.log(e)
|
|
|
|
- return false
|
|
|
|
- } finally {
|
|
|
|
- if (logging) log('Successfully wrote tauri.conf.json')
|
|
|
|
- }
|
|
|
|
|
|
+ /* eslint-enable security/detect-object-injection */
|
|
|
|
+ })
|
|
|
|
+ const finalConf = merge(defaultConfig as any, customConfig as any) as UnknownObject
|
|
|
|
+
|
|
|
|
+ writeFileSync(path, JSON.stringify(finalConf, undefined, 2))
|
|
|
|
+ if (logging) log('Successfully wrote tauri.conf.json')
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -82,21 +81,15 @@ Run \`tauri init --force template\` to overwrite.`)
|
|
? `{ path = "${resolveTauriPath(tauriPath)}" }`
|
|
? `{ path = "${resolveTauriPath(tauriPath)}" }`
|
|
: `{ version = "${resolveCurrentTauriVersion()}" }`
|
|
: `{ version = "${resolveCurrentTauriVersion()}" }`
|
|
|
|
|
|
- try {
|
|
|
|
- removeSync(dir)
|
|
|
|
- copyTemplates({
|
|
|
|
- source: resolve(__dirname, '../../templates/src-tauri'),
|
|
|
|
- scope: {
|
|
|
|
- tauriDep
|
|
|
|
- },
|
|
|
|
- target: dir
|
|
|
|
- })
|
|
|
|
- } catch (e) {
|
|
|
|
- if (logging) console.log(e)
|
|
|
|
- return false
|
|
|
|
- } finally {
|
|
|
|
- if (logging) log('Successfully wrote src-tauri')
|
|
|
|
- }
|
|
|
|
|
|
+ removeSync(dir)
|
|
|
|
+ copyTemplates({
|
|
|
|
+ source: resolve(__dirname, '../../templates/src-tauri'),
|
|
|
|
+ scope: {
|
|
|
|
+ tauriDep
|
|
|
|
+ },
|
|
|
|
+ target: dir
|
|
|
|
+ })
|
|
|
|
+ if (logging) log('Successfully wrote src-tauri')
|
|
}
|
|
}
|
|
|
|
|
|
const inject = (
|
|
const inject = (
|