From 7c9646beac232857d6adf94ac530dfc73bb5982c Mon Sep 17 00:00:00 2001 From: Vlad Frangu Date: Fri, 25 Oct 2024 13:01:42 +0300 Subject: [PATCH] fix: scrapy wrapping being broken due to ESM migration (#686) --- src/lib/projects/scrapy/wrapScrapyProject.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/lib/projects/scrapy/wrapScrapyProject.ts b/src/lib/projects/scrapy/wrapScrapyProject.ts index 74885ecb..1bb2390e 100644 --- a/src/lib/projects/scrapy/wrapScrapyProject.ts +++ b/src/lib/projects/scrapy/wrapScrapyProject.ts @@ -9,6 +9,7 @@ import { writeFileSync, } from 'node:fs'; import { basename, join, relative, sep } from 'node:path'; +import { fileURLToPath } from 'node:url'; import { fetchManifest, wrapperManifestUrl } from '@apify/actor-templates'; import rootWalk from '@root/walk'; @@ -25,6 +26,8 @@ import { downloadAndUnzip, sanitizeActorName } from '../../utils.js'; */ const concatenableFiles = ['.dockerignore', '.gitignore']; +const templatePath = fileURLToPath(new URL('./templates/python-scrapy', import.meta.url)); + async function merge( fromPath: string, toPath: string, @@ -120,7 +123,6 @@ export async function wrapScrapyProject({ projectPath }: { projectPath?: string info({ message: 'Downloading the latest Scrapy wrapper template...' }); const { archiveUrl } = manifest.templates.find(({ id }) => id === 'python-scrapy')!; - const templatePath = join(__dirname, 'templates', 'python-scrapy'); if (existsSync(templatePath)) rmSync(templatePath, { recursive: true }); @@ -131,7 +133,7 @@ export async function wrapScrapyProject({ projectPath }: { projectPath?: string info({ message: 'Wrapping the Scrapy project...' }); - await merge(join(__dirname, 'templates', 'python-scrapy'), projectPath, { + await merge(templatePath, projectPath, { bindings: templateBindings, });