diff --git a/scripts/copy_bundle_assets.js b/scripts/copy_bundle_assets.js index 4291afbed..1b2b5099b 100644 --- a/scripts/copy_bundle_assets.js +++ b/scripts/copy_bundle_assets.js @@ -17,17 +17,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { - copyFileSync, - existsSync, - mkdirSync, - statSync, - readdirSync, - chmodSync, -} from 'node:fs'; +import { copyFileSync, existsSync, mkdirSync, statSync } from 'node:fs'; import { dirname, join, basename } from 'node:path'; import { fileURLToPath } from 'node:url'; import { glob } from 'glob'; +import fs from 'node:fs'; const __dirname = dirname(fileURLToPath(import.meta.url)); const root = join(__dirname, '..'); @@ -62,7 +56,7 @@ console.log('\n✅ All bundle assets copied to dist/'); /** * Recursively copy directory */ -export function copyRecursiveSync(src, dest) { +function copyRecursiveSync(src, dest) { if (!existsSync(src)) { return; } @@ -74,7 +68,7 @@ export function copyRecursiveSync(src, dest) { mkdirSync(dest, { recursive: true }); } - const entries = readdirSync(src); + const entries = fs.readdirSync(src); for (const entry of entries) { // Skip .DS_Store files if (entry === '.DS_Store') { @@ -90,7 +84,7 @@ export function copyRecursiveSync(src, dest) { // Preserve execute permissions for binaries const srcStats = statSync(src); if (srcStats.mode & 0o111) { - chmodSync(dest, srcStats.mode); + fs.chmodSync(dest, srcStats.mode); } } } diff --git a/scripts/copy_files.js b/scripts/copy_files.js index efaad7498..9f1d318e9 100644 --- a/scripts/copy_files.js +++ b/scripts/copy_files.js @@ -49,10 +49,7 @@ function copyFilesRecursive(source, target, rootSourceDir) { const normalizedPath = relativePath.replace(/\\/g, '/'); const isLocaleJs = ext === '.js' && normalizedPath.startsWith('i18n/locales/'); - const isInsightTemplate = normalizedPath.startsWith( - 'services/insight/templates/', - ); - if (extensionsToCopy.includes(ext) || isLocaleJs || isInsightTemplate) { + if (extensionsToCopy.includes(ext) || isLocaleJs) { fs.copyFileSync(sourcePath, targetPath); } } diff --git a/scripts/prepare-package.js b/scripts/prepare-package.js index 24297fcef..de94e8d81 100644 --- a/scripts/prepare-package.js +++ b/scripts/prepare-package.js @@ -14,7 +14,6 @@ import fs from 'node:fs'; import path from 'node:path'; import { fileURLToPath } from 'node:url'; import { execSync } from 'node:child_process'; -import { copyRecursiveSync } from './copy_bundle_assets.js'; const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); @@ -70,6 +69,24 @@ const localesSourceDir = path.join( const localesDestDir = path.join(distDir, 'locales'); if (fs.existsSync(localesSourceDir)) { + // Recursive copy function + function copyRecursiveSync(src, dest) { + const stats = fs.statSync(src); + if (stats.isDirectory()) { + if (!fs.existsSync(dest)) { + fs.mkdirSync(dest, { recursive: true }); + } + const entries = fs.readdirSync(src); + for (const entry of entries) { + const srcPath = path.join(src, entry); + const destPath = path.join(dest, entry); + copyRecursiveSync(srcPath, destPath); + } + } else { + fs.copyFileSync(src, dest); + } + } + copyRecursiveSync(localesSourceDir, localesDestDir); console.log('Copied locales folder'); } else { @@ -90,6 +107,24 @@ const extensionExamplesDir = path.join( const extensionExamplesDestDir = path.join(distDir, 'examples'); if (fs.existsSync(extensionExamplesDir)) { + // Recursive copy function + function copyRecursiveSync(src, dest) { + const stats = fs.statSync(src); + if (stats.isDirectory()) { + if (!fs.existsSync(dest)) { + fs.mkdirSync(dest, { recursive: true }); + } + const entries = fs.readdirSync(src); + for (const entry of entries) { + const srcPath = path.join(src, entry); + const destPath = path.join(dest, entry); + copyRecursiveSync(srcPath, destPath); + } + } else { + fs.copyFileSync(src, dest); + } + } + copyRecursiveSync(extensionExamplesDir, extensionExamplesDestDir); console.log('Copied extension examples folder'); } else { @@ -98,28 +133,6 @@ if (fs.existsSync(extensionExamplesDir)) { ); } -// Copy insight templates directory -console.log('Copying insight templates...'); -const insightTemplatesDir = path.join( - rootDir, - 'packages', - 'cli', - 'src', - 'services', - 'insight', - 'templates', -); -const destTemplatesDir = path.join(distDir, 'templates'); - -if (fs.existsSync(insightTemplatesDir)) { - copyRecursiveSync(insightTemplatesDir, destTemplatesDir); - console.log('Copied insight templates to dist/'); -} else { - console.warn( - `Warning: Insight templates directory not found at ${insightTemplatesDir}`, - ); -} - // Copy package.json from root and modify it for publishing console.log('Creating package.json for distribution...'); const rootPackageJson = JSON.parse( @@ -138,15 +151,7 @@ const distPackageJson = { bin: { qwen: 'cli.js', }, - files: [ - 'cli.js', - 'vendor', - '*.sb', - 'README.md', - 'LICENSE', - 'locales', - 'templates', - ], + files: ['cli.js', 'vendor', '*.sb', 'README.md', 'LICENSE', 'locales'], config: rootPackageJson.config, dependencies: {}, optionalDependencies: {