refactor: remove deprecated native shell installers

- Remove installers/ directory (install.sh, install.ps1, uninstall.sh, uninstall.ps1)
- Update CloudFlare worker to 301 redirect /install* to npm docs
- Remove detectInstallationMethod() - npm is now only install method
- Simplify update-command.ts to npm-only updates
- Clean up tests to remove direct install references

BREAKING CHANGE: Native shell installers (curl/irm) no longer work.
Use `npm install -g @kaitranntt/ccs` instead.
This commit is contained in:
kaitranntt committed 2025-12-18 16:52:57 -05:00
1 parent be2b87ba98
commit 126cffc6dc
10 files changed
+51 -2385

No files matched your search

+18 -38
View File
@@ -1,46 +1,26 @@
/**
* CCS CloudFlare Worker - Redirect to npm Installation
*
* Legacy shell installers are deprecated. This worker now redirects
* all /install* and /uninstall* requests to the npm installation docs.
*/
export default {
async fetch(request) {
const url = new URL(request.url);
const docsUrl = 'https://docs.ccs.kaitran.ca/getting-started/installation';
// Detect platform from User-Agent header
const userAgent = request.headers.get('user-agent') || '';
const isWindows = userAgent.includes('Windows') || userAgent.includes('Win32');
const isPowerShell = userAgent.includes('PowerShell') || userAgent.includes('pwsh');
// Smart routing with platform detection
let filePath;
if (url.pathname === '/install' || url.pathname === '/install.sh') {
filePath = (isWindows && isPowerShell) ? 'installers/install.ps1' : 'installers/install.sh';
} else if (url.pathname === '/install.ps1') {
filePath = 'installers/install.ps1';
} else if (url.pathname === '/uninstall' || url.pathname === '/uninstall.sh') {
filePath = (isWindows && isPowerShell) ? 'installers/uninstall.ps1' : 'installers/uninstall.sh';
} else if (url.pathname === '/uninstall.ps1') {
filePath = 'installers/uninstall.ps1';
} else {
return new Response('Not Found', { status: 404 });
// Redirect all install/uninstall paths to npm installation docs
if (
url.pathname === '/install' ||
url.pathname === '/install.sh' ||
url.pathname === '/install.ps1' ||
url.pathname === '/uninstall' ||
url.pathname === '/uninstall.sh' ||
url.pathname === '/uninstall.ps1'
) {
return Response.redirect(docsUrl, 301);
}
try {
const githubUrl = `https://raw.githubusercontent.com/kaitranntt/ccs/main/${filePath}`;
const response = await fetch(githubUrl);
if (!response.ok) {
return new Response('File not found on GitHub', { status: 404 });
}
const contentType = filePath.endsWith('.ps1')
? 'text/plain; charset=utf-8'
: 'text/x-shellscript; charset=utf-8';
return new Response(response.body, {
headers: {
'Content-Type': contentType,
'Cache-Control': 'public, max-age=300'
}
});
} catch (error) {
return new Response('Server Error', { status: 500 });
}
return new Response('Not Found', { status: 404 });
}
};