Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,18 @@ on:
jobs:
push_image:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- uses: actions/checkout@v7
- uses: actions/setup-node@v6
with:
node-version: '14'
node-version: '20'
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
uses: aws-actions/configure-aws-credentials@v5
with:
# Created the Secrets Under the Repo only with These Variables
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
role-to-assume: arn:aws:iam::480535519801:role/github-actions-dev-story-scraper
aws-region: ${{ secrets.AWS_REGION }}
- name: install
run: |
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v7

- uses: actions/setup-node@v2
- uses: actions/setup-node@v6
with:
node-version: '14'
node-version: '20'

- name: install
run: yarn install
Expand Down
1 change: 1 addition & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type {Config} from '@jest/types';
const config: Config.InitialOptions = {
preset: 'ts-jest',
testEnvironment: 'node',
setupFilesAfterEnv: ['<rootDir>/src/tests/setupTests.ts'],
};

export default config;
2 changes: 1 addition & 1 deletion src/devStoryScraper.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import cheerio from 'cheerio';
import * as cheerio from 'cheerio';
import cleanDeep from 'clean-deep';

import {DevStoryDownloader} from './downloader/devStoryDownloader';
Expand Down
2 changes: 1 addition & 1 deletion src/parsers/companyUrlParser.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {HttpClient} from '../clients/httpClient';
import cheerio from 'cheerio';
import * as cheerio from 'cheerio';

export class CompanyUrlParser {
constructor(private readonly httpClient: HttpClient) {}
Expand Down
3 changes: 2 additions & 1 deletion src/parsers/devStory/devStoryArtifactParser.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import cheerio, {CheerioAPI} from 'cheerio';
import * as cheerio from 'cheerio';
import {CheerioAPI} from 'cheerio';

import {DevStoryArtifact, DevStoryArtifactType} from '../../models/devStory/devStoryArtifact';
import {stripString} from '../../utils/utils';
Expand Down
2 changes: 1 addition & 1 deletion src/parsers/devStory/devStoryBookmarkParse.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as _ from 'lodash';
import cheerio from 'cheerio';
import * as cheerio from 'cheerio';
import {Author, Bookmark} from '../../models/bookmark';
import {asNameAndSurnames, stripString} from '../../utils/utils';
import {Markdown} from '../../utils/markdown';
Expand Down
3 changes: 2 additions & 1 deletion src/parsers/devStory/devStoryPositionParser.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import cheerio, {CheerioAPI} from 'cheerio';
import * as cheerio from 'cheerio';
import {CheerioAPI} from 'cheerio';

import {DevStoryPosition} from '../../models/devStory/devStoryPosition';
import {stripString} from '../../utils/utils';
Expand Down
3 changes: 2 additions & 1 deletion src/parsers/devStory/devStoryTopsParser.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import cheerio, {CheerioAPI} from 'cheerio';
import * as cheerio from 'cheerio';
import {CheerioAPI} from 'cheerio';
import {PublicArtifact} from '../../models/publicArtifact';
import {stripString} from '../../utils/utils';

Expand Down
55 changes: 55 additions & 0 deletions src/tests/setupTests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// 1. Requerir módulos nativos de forma imperativa sin colisionar con tipos globales de TS
const streamWeb = require('node:stream/web');
const bufferModule = require('node:buffer');
const workerThreads = require('node:worker_threads');

// 2. Definir de forma prioritaria las clases de WebIDL en el global de Jest
if (typeof global.ReadableStream === 'undefined') {
global.ReadableStream = streamWeb.ReadableStream;
}
if (typeof global.WritableStream === 'undefined') {
global.WritableStream = streamWeb.WritableStream;
}
if (typeof global.TransformStream === 'undefined') {
global.TransformStream = streamWeb.TransformStream;
}
if (typeof global.Blob === 'undefined') {
global.Blob = bufferModule.Blob;
}
if (typeof global.File === 'undefined') {
global.File = bufferModule.File;
}
if (typeof global.MessagePort === 'undefined') {
global.MessagePort = workerThreads.MessagePort;
}
if (typeof global.MessageChannel === 'undefined') {
global.MessageChannel = workerThreads.MessageChannel;
}

if (typeof global.DOMException === 'undefined') {
global.DOMException = class DOMException extends Error {
constructor(message?: any, name?: any) {
super(message);
this.name = name || 'DOMException';
}
} as any;
}

// 3. Requerir undici de forma segura (una vez que todas las globales ya están inyectadas)
const undici = require('undici');

if (typeof global.fetch === 'undefined') {
global.fetch = undici.fetch;
}
if (typeof global.Headers === 'undefined') {
global.Headers = undici.Headers;
}
if (typeof global.Request === 'undefined') {
global.Request = undici.Request;
}
if (typeof global.Response === 'undefined') {
global.Response = undici.Response;
}
if (typeof global.FormData === 'undefined') {
global.FormData = undici.FormData;
}