Skip to content

Commit 0079f35

Browse files
committed
fixes
1 parent 4676379 commit 0079f35

File tree

18 files changed

+451
-276
lines changed

18 files changed

+451
-276
lines changed
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
import glob from 'glob';
2+
import { resolve } from 'path';
3+
import touch from 'touch';
4+
import type { Compiler, Compilation } from 'webpack';
5+
6+
interface WebpackWatchPluginOptions extends Omit<any, 'absolute'> {
7+
files?: string[];
8+
verbose?: boolean;
9+
}
10+
11+
class WebpackWatchPlugin {
12+
private files: string[];
13+
private verbose: boolean;
14+
private globOptions: any;
15+
private filesAlreadyAdded: boolean;
16+
17+
constructor(options: WebpackWatchPluginOptions = {}) {
18+
const { files = [], verbose, ...globOptions } = options;
19+
20+
this.files = files;
21+
this.verbose = !!verbose;
22+
this.globOptions = {
23+
absolute: true,
24+
...globOptions,
25+
};
26+
this.filesAlreadyAdded = false;
27+
}
28+
29+
apply(compiler: Compiler): void {
30+
compiler.hooks.afterCompile.tapAsync(
31+
'WebpackWatchPlugin',
32+
(compilation: Compilation, callback: () => void) => {
33+
const filesFound: string[] = [];
34+
const filesFoundToExclude: string[] = [];
35+
36+
for (const pattern of this.files) {
37+
if (pattern.substr(0, 1) !== '!') {
38+
glob.sync(pattern, this.globOptions).forEach((file) => {
39+
filesFound.push(file);
40+
});
41+
} else {
42+
glob.sync(pattern.substr(1), this.globOptions).forEach((file) => {
43+
filesFoundToExclude.push(file);
44+
});
45+
}
46+
}
47+
48+
const files = (
49+
(
50+
filesFound.map((file) => {
51+
if (filesFoundToExclude.indexOf(file) !== -1) {
52+
return null;
53+
}
54+
return file;
55+
})
56+
)
57+
).filter((file) => file !== null).map((file) => resolve(file));
58+
59+
if (this.verbose && !this.filesAlreadyAdded) {
60+
console.log('Additional files watched:', JSON.stringify(files, null, 2));
61+
}
62+
console.log({ files });
63+
64+
files.forEach((file) => {
65+
compilation.fileDependencies.add(file);
66+
});
67+
68+
this.filesAlreadyAdded = true;
69+
70+
const outputPath = compilation.outputOptions.path;
71+
const assets = compilation.getAssets();
72+
if (assets.length > 0 && outputPath) {
73+
const firstAssetName = assets[0].name;
74+
const assetToTouch = resolve(outputPath, firstAssetName);
75+
touch(assetToTouch);
76+
}
77+
78+
callback();
79+
}
80+
);
81+
}
82+
}
83+
84+
export default WebpackWatchPlugin;
85+

.erb/configs/webpack.config.main.dev.ts

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,7 @@ import webpackPaths from './webpack.paths';
1111
import { devMainCopyPlugins } from './copy-plugin'
1212
import { GenerateApiPropsPlugin } from './webpack.custom-plugins'
1313
import { getAnalyzerPlugins } from './getAnalyzerPlugins'
14-
import WatchExternalFilesPlugin from 'webpack-watch-files-plugin'
15-
import touch from 'touch';
16-
17-
18-
class WebpackForceRebuildOnEmitPlugin {
19-
apply(compiler) {
20-
compiler.hooks.emit.tapAsync('WebpackForceRebuildOnEmitPlugin', (compilation, callback) => {
21-
const outputPath = compilation.outputOptions.path;
22-
const firstAssetName = compilation.getAssets()[0].name;
23-
const assetToTouch = path.resolve(outputPath, firstAssetName);
24-
touch(assetToTouch);
25-
callback();
26-
});
27-
}
28-
}
29-
14+
import WatchExternalFilesPlugin from './webpack-watch-files-plugin'
3015

3116
function getWatchingPlugins() {
3217
const IS_WATCH_MODE = process.argv?.includes('--watch');
@@ -36,9 +21,8 @@ function getWatchingPlugins() {
3621
verbose: false,
3722
files: [
3823
'./inputs/**/*.js',
39-
]
24+
],
4025
}) as any,
41-
new WebpackForceRebuildOnEmitPlugin(),
4226
] : []
4327
}
4428
// When an ESLint server is running, we can't set the NODE_ENV so we'll check if it's

Dockerfile

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,6 @@ FROM node:20
33
ENV DEBIAN_FRONTEND=noninteractive \
44
DISPLAY=:99
55

6-
# Install system dependencies
7-
# RUN apt-get update && apt-get install -y --no-install-recommends \
8-
# wget \
9-
# git \
10-
# lsof \
11-
# xvfb \
12-
# gnupg \
13-
# ca-certificates \
14-
# && rm -rf /var/lib/apt/lists/*
15-
16-
# Install Chromium (works on both AMD64 and ARM64)
17-
# RUN apt-get update \
18-
# && apt-get install -y --no-install-recommends chromium \
19-
# && rm -rf /var/lib/apt/lists/* \
20-
# && ln -sf /usr/bin/chromium /usr/bin/google-chrome-stable \
21-
# && ln -sf /usr/bin/chromium /usr/bin/google-chrome
22-
23-
246
# # Install Chrome dependencies
257
RUN apt-get update && apt-get install -y \
268
wget \
@@ -44,8 +26,12 @@ RUN apt-get update && apt-get install -y google-chrome-stable \
4426
WORKDIR /app
4527

4628
COPY package*.json ./
47-
COPY . .
29+
COPY tsconfig.json ./
30+
COPY release/ ./release/
31+
COPY .erb/ ./.erb/
32+
4833
RUN npm install
34+
COPY . .
4935

5036

5137
EXPOSE 8000

package-lock.json

Lines changed: 1 addition & 62 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"clean:db": "rimraf output/ error_logs/ task_results/ db.nedb",
3030
"update": "npm update botasaurus botasaurus-controls botasaurus-server",
3131
"start:main": "concurrently -k \"cross-env NODE_ENV=development TS_NODE_TRANSPILE_ONLY=true webpack --watch --config ./.erb/configs/webpack.config.main.dev.ts\" \"electronmon .\"",
32-
"start:main:worker": "concurrently -k \"cross-env NODE_ENV=development TS_NODE_TRANSPILE_ONLY=true webpack --watch --config ./.erb/configs/webpack.config.main.dev.ts\" \"electronmon . --worker\"",
32+
"start:main:worker": "concurrently -k \"cross-env NODE_ENV=development TS_NODE_TRANSPILE_ONLY=true webpack --watch --config ./.erb/configs/webpack.config.main.dev.ts\" \"electronmon . --worker --no-sandbox\"",
3333
"start:main:master": "concurrently -k \"cross-env NODE_ENV=development TS_NODE_TRANSPILE_ONLY=true webpack --watch --config ./.erb/configs/webpack.config.main.dev.ts\" \"electronmon . --master\"",
3434
"start:preload": "cross-env NODE_ENV=development TS_NODE_TRANSPILE_ONLY=true webpack --config ./.erb/configs/webpack.config.preload.dev.ts",
3535
"start:renderer": "cross-env NODE_ENV=development TS_NODE_TRANSPILE_ONLY=true webpack serve --config ./.erb/configs/webpack.config.renderer.dev.ts",
@@ -139,8 +139,7 @@
139139
"webpack-bundle-analyzer": "^4.9.1",
140140
"webpack-cli": "^5.1.4",
141141
"webpack-dev-server": "^4.15.1",
142-
"webpack-merge": "^5.9.0",
143-
"webpack-watch-files-plugin": "^1.2.1"
142+
"webpack-merge": "^5.9.0"
144143
},
145144
"build": {
146145
"productName": "Todo My App Name",

release/app/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

release/app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "todo-my-app-name",
3-
"version": "1.40.0",
3+
"version": "1.41.0",
44
"description": "Todo my app description",
55
"license": "MIT",
66
"main": "./dist/main/main.js",

src/main/utils/set-up-renderer-to-server-call.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export function addRoutesHandler() {
2323
return pickId(result)
2424
}
2525

26-
return result.slice(0, 1).map(pickId)
26+
return [pickId(result[1] ?? result[0])]
2727
})
2828
} else {
2929
// @ts-ignore

src/renderer/app/components/InputComponent/InputComponent.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import SearchSingleSelectApi from '../inputs/SearchSingleSelectApi';
2727
import SearchMultiSelectApi from '../inputs/SearchMultiSelectApi';
2828
import SwitchField from '../inputs/SwitchField';
2929
import TextAreaField from '../inputs/TextAreaField';
30+
import JsonTextAreaField from '../inputs/JsonTextAreaField';
3031
import TextField from '../inputs/TextField';
3132
import { useRouter } from '../Link';
3233
import ScraperSelector from '../ScraperSelector/ScraperSelector';
@@ -175,6 +176,18 @@ const InputFields = ({
175176
/>
176177
)
177178
break
179+
case 'jsonTextArea':
180+
inputElement = (
181+
<JsonTextAreaField
182+
title={disabledMsg}
183+
disabled={disabled}
184+
placeholder={(control as any).placeholder}
185+
name={id}
186+
value={data[id]}
187+
onChange={value => handleInputChange(id, value)}
188+
/>
189+
)
190+
break
178191
case 'number':
179192
inputElement = (
180193
<NumberField
@@ -537,13 +550,11 @@ const ScraperFormContainer = ({ scrapers, enable_cache }) => {
537550
e?.preventDefault()
538551
setSubmitAttempted(true)
539552
if (isEmptyObject(validationResult)) {
540-
// @ts-ignore
541-
const cleanedData = controls.getBackendValidationResult(data)['data']
542553
setIsSubmitting(true)
543554
try {
544555
const response = await Api.createAsyncTask({
545556
scraper_name: selectedScraper.scraper_name,
546-
data: cleanedData,
557+
data,
547558
enable_cache: enableCache}).finally(() => setIsSubmitting(false))
548559
if (response) {
549560
const result = response.data

0 commit comments

Comments
 (0)