mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-03-21 00:11:27 -07:00
Prepare Windows release and signing process (#16)
This commit is contained in:
@@ -24,13 +24,17 @@ function withTempDir(fn: (dir: string) => void): void {
|
||||
}
|
||||
|
||||
test('getDefaultConfigDir prefers existing SubMiner config directory', () => {
|
||||
const xdgConfigHome = path.join(path.sep, 'tmp', 'xdg');
|
||||
const homeDir = path.join(path.sep, 'tmp', 'home');
|
||||
const dir = getDefaultConfigDir({
|
||||
xdgConfigHome: '/tmp/xdg',
|
||||
homeDir: '/tmp/home',
|
||||
existsSync: (candidate) => candidate === '/tmp/xdg/SubMiner/config.jsonc',
|
||||
platform: 'linux',
|
||||
xdgConfigHome,
|
||||
homeDir,
|
||||
existsSync: (candidate) =>
|
||||
candidate === path.posix.join(xdgConfigHome, 'SubMiner', 'config.jsonc'),
|
||||
});
|
||||
|
||||
assert.equal(dir, '/tmp/xdg/SubMiner');
|
||||
assert.equal(dir, path.posix.join(xdgConfigHome, 'SubMiner'));
|
||||
});
|
||||
|
||||
test('ensureDefaultConfigBootstrap creates config dir and default jsonc only when missing', () => {
|
||||
@@ -61,6 +65,26 @@ test('ensureDefaultConfigBootstrap creates config dir and default jsonc only whe
|
||||
});
|
||||
});
|
||||
|
||||
test('ensureDefaultConfigBootstrap does not seed default config into an existing config directory', () => {
|
||||
withTempDir((root) => {
|
||||
const configDir = path.join(root, 'SubMiner');
|
||||
fs.mkdirSync(configDir, { recursive: true });
|
||||
fs.writeFileSync(path.join(configDir, 'existing-user-file.txt'), 'keep\n');
|
||||
|
||||
ensureDefaultConfigBootstrap({
|
||||
configDir,
|
||||
configFilePaths: getDefaultConfigFilePaths(configDir),
|
||||
generateTemplate: () => 'should-not-write',
|
||||
});
|
||||
|
||||
assert.equal(fs.existsSync(path.join(configDir, 'config.jsonc')), false);
|
||||
assert.equal(
|
||||
fs.readFileSync(path.join(configDir, 'existing-user-file.txt'), 'utf8'),
|
||||
'keep\n',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
test('readSetupState ignores invalid files and round-trips valid state', () => {
|
||||
withTempDir((root) => {
|
||||
const statePath = getSetupStatePath(root);
|
||||
@@ -77,22 +101,126 @@ test('readSetupState ignores invalid files and round-trips valid state', () => {
|
||||
});
|
||||
});
|
||||
|
||||
test('resolveDefaultMpvInstallPaths resolves linux and macOS defaults', () => {
|
||||
assert.deepEqual(resolveDefaultMpvInstallPaths('linux', '/tmp/home', '/tmp/xdg'), {
|
||||
supported: true,
|
||||
mpvConfigDir: '/tmp/xdg/mpv',
|
||||
scriptsDir: '/tmp/xdg/mpv/scripts',
|
||||
scriptOptsDir: '/tmp/xdg/mpv/script-opts',
|
||||
pluginDir: '/tmp/xdg/mpv/scripts/subminer',
|
||||
pluginConfigPath: '/tmp/xdg/mpv/script-opts/subminer.conf',
|
||||
});
|
||||
test('readSetupState migrates v1 state to v2 windows shortcut defaults', () => {
|
||||
withTempDir((root) => {
|
||||
const statePath = getSetupStatePath(root);
|
||||
fs.writeFileSync(
|
||||
statePath,
|
||||
JSON.stringify({
|
||||
version: 1,
|
||||
status: 'incomplete',
|
||||
completedAt: null,
|
||||
completionSource: null,
|
||||
lastSeenYomitanDictionaryCount: 0,
|
||||
pluginInstallStatus: 'unknown',
|
||||
pluginInstallPathSummary: null,
|
||||
}),
|
||||
);
|
||||
|
||||
assert.deepEqual(resolveDefaultMpvInstallPaths('darwin', '/Users/tester', undefined), {
|
||||
supported: true,
|
||||
mpvConfigDir: '/Users/tester/Library/Application Support/mpv',
|
||||
scriptsDir: '/Users/tester/Library/Application Support/mpv/scripts',
|
||||
scriptOptsDir: '/Users/tester/Library/Application Support/mpv/script-opts',
|
||||
pluginDir: '/Users/tester/Library/Application Support/mpv/scripts/subminer',
|
||||
pluginConfigPath: '/Users/tester/Library/Application Support/mpv/script-opts/subminer.conf',
|
||||
assert.deepEqual(readSetupState(statePath), {
|
||||
version: 2,
|
||||
status: 'incomplete',
|
||||
completedAt: null,
|
||||
completionSource: null,
|
||||
lastSeenYomitanDictionaryCount: 0,
|
||||
pluginInstallStatus: 'unknown',
|
||||
pluginInstallPathSummary: null,
|
||||
windowsMpvShortcutPreferences: {
|
||||
startMenuEnabled: true,
|
||||
desktopEnabled: true,
|
||||
},
|
||||
windowsMpvShortcutLastStatus: 'unknown',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
test('resolveDefaultMpvInstallPaths resolves linux, macOS, and Windows defaults', () => {
|
||||
const linuxHomeDir = path.join(path.sep, 'tmp', 'home');
|
||||
const xdgConfigHome = path.join(path.sep, 'tmp', 'xdg');
|
||||
assert.deepEqual(resolveDefaultMpvInstallPaths('linux', linuxHomeDir, xdgConfigHome), {
|
||||
supported: true,
|
||||
mpvConfigDir: path.posix.join(xdgConfigHome, 'mpv'),
|
||||
scriptsDir: path.posix.join(xdgConfigHome, 'mpv', 'scripts'),
|
||||
scriptOptsDir: path.posix.join(xdgConfigHome, 'mpv', 'script-opts'),
|
||||
pluginEntrypointPath: path.posix.join(xdgConfigHome, 'mpv', 'scripts', 'subminer', 'main.lua'),
|
||||
pluginDir: path.posix.join(xdgConfigHome, 'mpv', 'scripts', 'subminer'),
|
||||
pluginConfigPath: path.posix.join(xdgConfigHome, 'mpv', 'script-opts', 'subminer.conf'),
|
||||
});
|
||||
|
||||
const macHomeDir = path.join(path.sep, 'Users', 'tester');
|
||||
assert.deepEqual(resolveDefaultMpvInstallPaths('darwin', macHomeDir, undefined), {
|
||||
supported: true,
|
||||
mpvConfigDir: path.posix.join(macHomeDir, 'Library', 'Application Support', 'mpv'),
|
||||
scriptsDir: path.posix.join(macHomeDir, 'Library', 'Application Support', 'mpv', 'scripts'),
|
||||
scriptOptsDir: path.posix.join(
|
||||
macHomeDir,
|
||||
'Library',
|
||||
'Application Support',
|
||||
'mpv',
|
||||
'script-opts',
|
||||
),
|
||||
pluginEntrypointPath: path.posix.join(
|
||||
macHomeDir,
|
||||
'Library',
|
||||
'Application Support',
|
||||
'mpv',
|
||||
'scripts',
|
||||
'subminer',
|
||||
'main.lua',
|
||||
),
|
||||
pluginDir: path.posix.join(
|
||||
macHomeDir,
|
||||
'Library',
|
||||
'Application Support',
|
||||
'mpv',
|
||||
'scripts',
|
||||
'subminer',
|
||||
),
|
||||
pluginConfigPath: path.posix.join(
|
||||
macHomeDir,
|
||||
'Library',
|
||||
'Application Support',
|
||||
'mpv',
|
||||
'script-opts',
|
||||
'subminer.conf',
|
||||
),
|
||||
});
|
||||
|
||||
assert.deepEqual(resolveDefaultMpvInstallPaths('win32', 'C:\\Users\\tester', undefined), {
|
||||
supported: true,
|
||||
mpvConfigDir: path.win32.join('C:\\Users\\tester', 'AppData', 'Roaming', 'mpv'),
|
||||
scriptsDir: path.win32.join('C:\\Users\\tester', 'AppData', 'Roaming', 'mpv', 'scripts'),
|
||||
scriptOptsDir: path.win32.join(
|
||||
'C:\\Users\\tester',
|
||||
'AppData',
|
||||
'Roaming',
|
||||
'mpv',
|
||||
'script-opts',
|
||||
),
|
||||
pluginEntrypointPath: path.win32.join(
|
||||
'C:\\Users\\tester',
|
||||
'AppData',
|
||||
'Roaming',
|
||||
'mpv',
|
||||
'scripts',
|
||||
'subminer',
|
||||
'main.lua',
|
||||
),
|
||||
pluginDir: path.win32.join(
|
||||
'C:\\Users\\tester',
|
||||
'AppData',
|
||||
'Roaming',
|
||||
'mpv',
|
||||
'scripts',
|
||||
'subminer',
|
||||
),
|
||||
pluginConfigPath: path.win32.join(
|
||||
'C:\\Users\\tester',
|
||||
'AppData',
|
||||
'Roaming',
|
||||
'mpv',
|
||||
'script-opts',
|
||||
'subminer.conf',
|
||||
),
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user