mirror of
https://github.com/obsqrbtz/goose-highlighter.git
synced 2026-04-09 04:29:09 +03:00
chore: refactor
This commit is contained in:
39
scripts/build-content-standalone.js
Normal file
39
scripts/build-content-standalone.js
Normal file
@@ -0,0 +1,39 @@
|
||||
const fs = require('fs');
|
||||
|
||||
const typesContent = fs.readFileSync('src/types.ts', 'utf8');
|
||||
const domUtilsContent = fs.readFileSync('src/utils/DOMUtils.ts', 'utf8');
|
||||
const storageServiceContent = fs.readFileSync('src/services/StorageService.ts', 'utf8');
|
||||
const messageServiceContent = fs.readFileSync('src/services/MessageService.ts', 'utf8');
|
||||
const highlightEngineContent = fs.readFileSync('src/content/HighlightEngine.ts', 'utf8');
|
||||
const contentScriptContent = fs.readFileSync('src/content/ContentScript.ts', 'utf8');
|
||||
const mainContent = fs.readFileSync('src/main.ts', 'utf8');
|
||||
|
||||
function extractDefinitions(content, filename) {
|
||||
// Remove import statements
|
||||
let cleaned = content.replace(/^import\s+.*?;?\s*$/gm, '');
|
||||
|
||||
// Remove export keywords but keep the definitions
|
||||
cleaned = cleaned.replace(/^export\s+/gm, '');
|
||||
|
||||
// Add a comment header
|
||||
cleaned = `// === ${filename} ===\n${cleaned}\n`;
|
||||
|
||||
return cleaned;
|
||||
}
|
||||
|
||||
// Extract and combine all definitions
|
||||
const combinedContent = `// Auto-generated standalone content script
|
||||
// Do not edit this file directly - edit the source files and rebuild
|
||||
|
||||
${extractDefinitions(typesContent, 'types.ts')}
|
||||
${extractDefinitions(domUtilsContent, 'utils/DOMUtils.ts')}
|
||||
${extractDefinitions(storageServiceContent, 'services/StorageService.ts')}
|
||||
${extractDefinitions(messageServiceContent, 'services/MessageService.ts')}
|
||||
${extractDefinitions(highlightEngineContent, 'content/HighlightEngine.ts')}
|
||||
${extractDefinitions(contentScriptContent, 'content/ContentScript.ts')}
|
||||
${extractDefinitions(mainContent, 'main.ts')}
|
||||
`;
|
||||
|
||||
fs.writeFileSync('src/content-standalone.ts', combinedContent);
|
||||
|
||||
console.log('Generated standalone content script');
|
||||
@@ -2,7 +2,7 @@ const fs = require('fs');
|
||||
|
||||
const version = process.argv[2];
|
||||
if (!version) {
|
||||
console.log('ℹ️ No version passed, skipping manifest update');
|
||||
console.log('No version passed, skipping manifest update');
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
@@ -10,4 +10,4 @@ const manifest = JSON.parse(fs.readFileSync('manifest.json', 'utf-8'));
|
||||
manifest.version = version;
|
||||
fs.writeFileSync('manifest.json', JSON.stringify(manifest, null, 2));
|
||||
|
||||
console.log(`✅ Updated manifest.json to version ${version}`);
|
||||
console.log(`Updated manifest.json to version ${version}`);
|
||||
Reference in New Issue
Block a user