Skip to content

Commit

Permalink
Indexer module updates
Browse files Browse the repository at this point in the history
  • Loading branch information
dimitrov-d committed Oct 29, 2024
1 parent 1a3812b commit 4d31cc5
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 16 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@apillon/cli",
"description": "▶◀ Apillon CLI tools ▶◀",
"version": "1.4.0",
"version": "1.5.0",
"author": "Apillon",
"license": "MIT",
"main": "./dist/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@apillon/sdk",
"description": "▶◀ Apillon SDK for NodeJS ▶◀",
"version": "3.4.0",
"version": "3.5.0",
"author": "Apillon",
"license": "MIT",
"main": "./dist/index.js",
Expand Down
9 changes: 6 additions & 3 deletions packages/sdk/src/modules/indexing/indexer.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable security/detect-non-literal-fs-filename */
import axios from 'axios';
import fs from 'fs';
import { ApillonModel } from '../../lib/apillon';
Expand Down Expand Up @@ -40,10 +41,12 @@ export class Indexer extends ApillonModel {
public async deployIndexer(path: string): Promise<any> {
//Check directory and if squid.yaml exists in it
if (!fs.existsSync(path)) {
return console.error('Invalid path');
throw new Error('Error deploying indexer: Invalid path');
}
if (!fs.existsSync(`${path}/squid.yaml`)) {
return console.error('squid.yaml not found in directory');
throw new Error(
'Error deploying indexer: squid.yaml not found in directory',
);
}

//Create tar.gz file
Expand All @@ -53,7 +56,7 @@ export class Indexer extends ApillonModel {
);

if (numOfFiles === 0) {
return console.error('Source directory is empty');
throw new Error('Error deploying indexer: Source directory is empty');
}
ApillonLogger.log(`Compressed ${numOfFiles} files. Uploading to s3...`);

Expand Down
19 changes: 10 additions & 9 deletions packages/sdk/src/util/indexer-utils.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
/* eslint-disable security/detect-non-literal-fs-filename */
import fs from 'node:fs';
import path from 'node:path';
import { globSync } from 'glob';
import ignore from 'ignore';
import targz from 'targz';
import { ApillonLogger } from '../lib/apillon-logger';

export function createSquidIgnore(squidDir: string) {
const ig = ignore().add(
Expand Down Expand Up @@ -86,28 +88,27 @@ export function compressIndexerSourceCode(
src: srcDir,
dest: destDir,
tar: {
ignore: (name) => {
ignore: (name: string) => {
const relativePath = path.relative(
path.resolve(srcDir),
path.resolve(name),
);

if (squidIgnore.ignores(relativePath)) {
console.log('ignoring ' + relativePath);
ApillonLogger.log(`ignoring ${relativePath}`);
return true;
} else {
console.log('adding ' + relativePath);
filesCount++;
return false;
}
ApillonLogger.log(`adding ${relativePath}`);
filesCount++;
return false;
},
},
},
function (err) {
(err) => {
if (err) {
console.error(err);
ApillonLogger.log(err);
reject(
`Compression failed. ${err.message ? 'Error: ' + err.message : ''}`,
`Compression failed. ${err.message ? `Error: ${err.message}` : ''}`,
);
} else {
resolve(filesCount);
Expand Down

0 comments on commit 4d31cc5

Please sign in to comment.