<commit_before>const { net } = require('electron');
const path = require('path');
const fs = require('fs');
const { AVAILABLE_TYPE } = require('../../common/constants');
const NetworkZipHandlerStream = require('../utils/networkZipHandleStream');

module.exports = (moduleName) => new Promise((resolve, reject) => {
    if (!moduleName) {
        reject(new Error('moduleName it not present'));
        return;
    }

    const { moduleResourceUrl } = global.sharedObject;

    //TODO 개발간 임시
    const request = net.request(`${moduleResourceUrl}/${moduleName}`);
    request.on('response', (response) => {
        response.on('error', reject);
        if (response.statusCode === 200) {
            const moduleDirPath = path.resolve('app', 'modules');
            const zipStream = new NetworkZipHandlerStream(moduleDirPath);
            zipStream.on('done', () => {
                fs.readFile(
                    // path.join(moduleDirPath, `${moduleName}.json`),
                    path.join(moduleDirPath, 'metadata.json'),
                    (err, data) => {
                        if (err) {
                            reject(err);
                            return;
                        }
                        const configJson = JSON.parse(data);
                        configJson.availableType = AVAILABLE_TYPE.available;
                        resolve(configJson);
                    });
            });

            response.pipe(zipStream);
            response.on('end', () => {
                // nothing to do
            });
        } else {
            console.error('module request get not ok status');
            reject();
        }
    });
    request.end();
});
<commit_msg>metadata.json -> ${moduleName}.json 으로 수정<commit_after>const { net } = require('electron');
const path = require('path');
const fs = require('fs');
const { AVAILABLE_TYPE } = require('../../common/constants');
const NetworkZipHandlerStream = require('../utils/networkZipHandleStream');

module.exports = (moduleName) => new Promise((resolve, reject) => {
    if (!moduleName) {
        reject(new Error('moduleName it not present'));
        return;
    }

    const { moduleResourceUrl } = global.sharedObject;

    //TODO 개발간 임시
    const request = net.request(`${moduleResourceUrl}/${moduleName}`);
    request.on('response', (response) => {
        response.on('error', reject);
        if (response.statusCode === 200) {
            const moduleDirPath = path.resolve('app', 'modules');
            const zipStream = new NetworkZipHandlerStream(moduleDirPath);
            zipStream.on('done', () => {
                fs.readFile(
                    path.join(moduleDirPath, `${moduleName}.json`),
                    (err, data) => {
                        if (err) {
                            reject(err);
                            return;
                        }
                        const configJson = JSON.parse(data);
                        configJson.availableType = AVAILABLE_TYPE.available;
                        resolve(configJson);
                    });
            });

            response.pipe(zipStream);
            response.on('end', () => {
                // nothing to do
            });
        } else {
            console.error('module request get not ok status');
            reject();
        }
    });
    request.end();
});

{'fraction_non_alphanumeric': 0.1404494382022472, 'fraction_numerical': 0.0017740981667652277, 'mean_word_length': 1.6450351837372947, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4996370', 'n_tokens_mistral': 874, 'n_tokens_neox': 848, 'n_words': 169}