Fix webpack

This commit is contained in:
Alan O'Cull 2024-01-12 00:58:01 -05:00
parent f619c1cd80
commit ecf5d37728
6 changed files with 344 additions and 248 deletions

4
buildwin.cmd Normal file
View File

@ -0,0 +1,4 @@
rmdir dist\
REM mkdir dist\public
REM xcopy .\assets .\dist\public /e /h /y /f
tsc && webpack --config .\webpack\development.js --watch

495
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -4,8 +4,14 @@
"description": "Tool for basic mirroring issues, tasks, and commits between Gitea and Jira",
"main": "index.js",
"scripts": {
"server": "node ./src/index.js",
"test": "echo \"Error: no test specified\" && exit 1"
"all": "npm run clean && npm run build && npm run start",
"clean": "rm -rf build/ && rm -rf dist/",
"prebuild": "mkdir -p dist/public/ && cp -R assets/* dist/public/",
"build": "tsc && webpack --config ./webpack/development.js",
"rebuild": "npm run clean && npm run build",
"server": "node ./build/index.js",
"debug": "node ./build/index.js -debug",
"winserver": "node .\\build\\index.js"
},
"repository": {
"type": "git",
@ -22,7 +28,9 @@
"license": "ISC",
"dependencies": {
"body-parser": "^1.20.2",
"lodash": "^4.17.21"
"lodash": "^4.17.21",
"ts-loader": "^9.5.1",
"webpack-node-externals": "^3.0.0"
},
"devDependencies": {
"@types/body-parser": "^1.19.5",

View File

@ -1,69 +0,0 @@
const fs = require('fs');
const https = require('https');
const bodyParser = require('body-parser');
const _ = require('lodash');
const express = require('express');
const { append } = require('express/lib/response');
// LOAD CONFIGURATION
const CONFIG_DIRECTORY = `${process.cwd()}/config/`;
/** @var {Object} */
const CONFIG = JSON.parse(fs.readFileSync(`${CONFIG_DIRECTORY}server.json`, 'utf-8'));
const SECRETS = JSON.parse(fs.readFileSync(`${CONFIG_DIRECTORY}secrets.json`, 'utf-8'));
const PORT = CONFIG['port'];
// BUILD OAUTH
const OAUTH_JIRA = `${SECRETS['jira-email']}:${SECRETS['jira-token']}`;
const OAUTH_GITEA = `token=${SECRETS['gitea-token']}`;
const URL_GITEA = `${CONFIG['gitea']}/api/v1`;
// INITIALIZE EXPRESS AND SET UP WEBHOOKS
const app = express();
app.use(bodyParser.json());
app.get('/', (req, res) => {
console.log("Got request ", req.url);
res.send({'data':'nice'});
})
// FUNCTIONALITY
const fetch_issues = () => {
/** @type {Object} */
_.forEach(CONFIG['repositories'], (loc, key) => {
console.log(`KEY [${key}]: ${loc}`);
if (key !== 'bot') { return } // TESTING ONLY, skip if not bot repo
// Search for all open issues in the given repository
const reqURL = `${URL_GITEA}/repos/${loc}/issues?state=open&${OAUTH_GITEA}`;
const options = {
hostname: URL_GITEA,
port: 443,
path: `/repos/${loc}/issues?state=open&${OAUTH_GITEA}`,
method: 'GET',
accept: 'application/json'
};
console.log(`Sending request to ${reqURL}`);
const req = https.request(options, (res) => {
res.setEncoding('utf-8');
res.on('data', (d) => {
console.log(d);
});
});
req.on('error', (e) => {
console.error(e);
});
req.end();
});
}
fetch_issues();
// HOST
app.listen(PORT, () => {
console.log(`Server is running on localhost:${PORT}, working in ${CONFIG_DIRECTORY}`)
});

View File

@ -55,7 +55,7 @@
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
// "outDir": "./", /* Specify an output folder for all emitted files. */
"outDir": "./build", /* Specify an output folder for all emitted files. */
// "removeComments": true, /* Disable emitting comments. */
// "noEmit": true, /* Disable emitting files from a compilation. */
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */

View File

@ -29,7 +29,7 @@ const commonConfig = {
const serverConfig = _.defaultsDeep(_.cloneDeep(commonConfig), {
target: 'node',
entry: {
server: './src/index.ts',
index: './src/index.ts',
},
output: {
filename: '[name].js',
@ -57,8 +57,8 @@ const serverConfig = _.defaultsDeep(_.cloneDeep(commonConfig), {
// Automatically restart the server if it crashes.
ps.once('close', () => {
console.log('Crash detected, restarting ...');
startServer();
// console.log('Crash detected, restarting ...');
// startServer();
});
}
@ -83,4 +83,4 @@ const serverConfig = _.defaultsDeep(_.cloneDeep(commonConfig), {
],
});
module.exports = [clientConfig, serverConfig];
module.exports = [serverConfig];