Skip to content
This repository was archived by the owner on Aug 15, 2023. It is now read-only.

Commit 0b4e14a

Browse files
authored
chore: move tt-automation to platforms folder (#544)
1 parent 3fae71e commit 0b4e14a

File tree

146 files changed

+168
-1433
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

146 files changed

+168
-1433
lines changed
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"taboule": "yarn workspace @trex/taboule",
3131
"shared": "yarn workspace @trex/shared",
3232
"guardoni": "yarn workspace guardoni",
33+
"tt-automate": "yarn workspace tt-automate",
3334
"tk:docs": "yarn workspace @tktrex/docs",
3435
"tk:shared": "yarn workspace @tktrex/shared",
3536
"tk:backend": "yarn workspace @tktrex/backend",

platforms/guardoni/package.json

+1-8
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,10 @@
2020
"postinstall": "electron-builder install-app-deps",
2121
"prepack": "yarn build",
2222
"check-stealth": "ts-node ./bin/check-stealth.ts",
23-
"automate:dev": "ts-node ./src/tx-automate/index.ts",
24-
"automate": "node dist/index.js",
2523
"tdd": "jest --watch --verbose"
2624
},
2725
"bin": {
28-
"cli": "./bin/guardoni-cli.js",
29-
"tk-cli": "./bin/guardoni-tk-cli.js"
26+
"cli": "./bin/guardoni-cli.js"
3027
},
3128
"main": "./build/electron/main.js",
3229
"repository": {
@@ -70,8 +67,6 @@
7067
"lodash": "^4.17.21",
7168
"nconf": "^0.11.3",
7269
"node-fetch": "^2.6.7",
73-
"pouchdb-find": "^7.2.2",
74-
"pouchdb-node": "^7.2.2",
7570
"puppeteer-core": "^13.7.0",
7671
"puppeteer-extra": "^3.2.3",
7772
"puppeteer-extra-plugin-stealth": "^2.9.0",
@@ -89,8 +84,6 @@
8984
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.7",
9085
"@types/lodash": "^4.14.182",
9186
"@types/nconf": "^0.10.2",
92-
"@types/pouchdb-find": "^6.3.7",
93-
"@types/pouchdb-node": "^6.1.4",
9487
"@types/prettier": "^2.6.3",
9588
"@types/react": "^17.0.45",
9689
"@types/react-dom": "^17.0.17",

platforms/guardoni/src/guardoni/tx-automate/config.ts

-8
This file was deleted.

platforms/guardoni/tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"@tktrex/shared/*": ["../../tktrex/shared/src/*"]
3333
}
3434
},
35-
"include": ["./src", "__mocks__", "__tests__"],
35+
"include": ["./src", "__mocks__", "__tests__", "./typings"],
3636
"exclude": ["node_modules", "build", "dist"],
3737
"watchOptions": {
3838
"watchFile": "useFsEvents",

platforms/guardoni/webpack.config.ts

-54
Original file line numberDiff line numberDiff line change
@@ -162,48 +162,6 @@ guardoniConfig.module?.rules?.push(
162162
}
163163
);
164164

165-
const { buildENV: guardoniTkBuildEnv, ...guardoniTKConfig } = getConfig({
166-
cwd: __dirname,
167-
outputDir: path.resolve(__dirname, 'build/guardoni'),
168-
env: t.strict({}),
169-
hot: false,
170-
target: 'node16',
171-
entry: {
172-
'tk-cli': path.resolve(__dirname, 'src/guardoni/tx-automate/index.ts'),
173-
},
174-
});
175-
176-
guardoniTKConfig.module?.rules?.push(
177-
{
178-
// this is a hack to get webpack to be able to bundle
179-
// puppeteer-extra, found here:
180-
// https://github.com/berstend/puppeteer-extra/issues/93
181-
// this also requires the TypeScript to emit import / export statements
182-
// i.e. ES6+ nodules to work
183-
test: /node_modules\/puppeteer-extra\/dist\/index\.esm\.js/,
184-
loader: 'string-replace-loader',
185-
options: {
186-
// match a require function call where the argument isn't a string
187-
// also capture the first character of the args so we can ignore it later
188-
search: 'require[(]([^\'"])',
189-
// replace the 'require(' with a '__non_webpack_require__(', meaning it will require the files at runtime
190-
// $1 grabs the first capture group from the regex, the one character we matched and don't want to lose
191-
replace: '__non_webpack_require__($1',
192-
flags: 'g',
193-
},
194-
},
195-
{
196-
// also part of the puppeteer-extra hack
197-
test: /\.js$/,
198-
use: 'unlazy-loader',
199-
},
200-
{
201-
// this is required by canvas, part of linkedom
202-
test: /\.node$/,
203-
use: 'node-loader',
204-
}
205-
);
206-
207165
export default [
208166
{
209167
...rendererConfig,
@@ -226,16 +184,4 @@ export default [
226184
},
227185
devtool: 'source-map',
228186
},
229-
// guardoni TK cli
230-
{
231-
...guardoniTKConfig,
232-
output: {
233-
...guardoniTKConfig.output,
234-
libraryTarget: 'commonjs',
235-
},
236-
node: {
237-
__dirname: false,
238-
},
239-
devtool: 'source-map',
240-
},
241187
];

platforms/tktrex/automation/.vscode/settings.json

-8
This file was deleted.

platforms/tktrex/automation/webpack.config.ts

-65
This file was deleted.
File renamed without changes.
File renamed without changes.
File renamed without changes.

platforms/guardoni/bin/guardoni-tk-cli.js platforms/tt-automate/bin/cli.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
/* eslint-disable no-console */
44

5-
const { cli } = require('../build/guardoni/tk-cli.js');
5+
const { cli } = require('../build/cli.js');
66

77
cli.parse();

platforms/tktrex/automation/package.json platforms/tt-automate/package.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "@trex/tt-automation",
2+
"name": "tt-automate",
33
"version": "2.5.4",
44
"packageManager": "yarn@3.1.1",
55
"engines": {
@@ -14,6 +14,9 @@
1414
"test": "jest --verbose",
1515
"tdd": "jest --watch --verbose"
1616
},
17+
"bin": {
18+
"cli": "./bin/cli.js"
19+
},
1720
"main": "./dist/index.js",
1821
"devDependencies": {
1922
"@types/node": "^16.11.36",

platforms/tt-automate/src/config.ts

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import * as t from 'io-ts';
2+
3+
export const MinimalProjectConfig = t.type(
4+
{
5+
experimentType: t.string,
6+
useStealth: t.boolean,
7+
proxy: t.union([t.null, t.string]),
8+
},
9+
'MinimalProjectConfig'
10+
);
11+
export type MinimalProjectConfig = t.TypeOf<typeof MinimalProjectConfig>;

platforms/guardoni/src/guardoni/tx-automate/platform/TikTok/experiment/french-elections.ts platforms/tt-automate/src/platform/TikTok/experiment/french-elections.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ import { MinimalProjectConfig } from '../../../config';
66
import { ExperimentDescriptor } from '@experiment/index';
77
import { decodeOrThrow } from '@util/fp';
88
import { sleep } from '@util/misc';
9-
import { createHandleCaptcha, ensureLoggedIn } from '@platform/TikTok/util/page';
9+
import {
10+
createHandleCaptcha,
11+
ensureLoggedIn,
12+
} from '@platform/TikTok/util/page';
1013
import { parseSearchTop } from '@platform/TikTok/parser/index';
1114
import { loadQueriesCSV } from '@util/csv';
1215
import { fillInput } from '@util/page';
@@ -18,8 +21,6 @@ import {
1821
confirmPublicKeyNoted,
1922
} from '@platform/TikTok/util/project';
2023

21-
22-
2324
const Config = t.intersection(
2425
[
2526
MinimalProjectConfig,

platforms/guardoni/src/guardoni/tx-automate/project/init.ts platforms/tt-automate/src/project/init.ts

-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ import { shellEscape } from '@util/misc';
66
import { createLogger } from '@util/logger';
77
import experimentDescriptors from '@experiment/descriptors';
88

9-
10-
119
export const generateDirectoryStructure = (
1210
projectDirectory: string
1311
): Record<string, string> => ({

platforms/guardoni/src/guardoni/tx-automate/project/run.ts platforms/tt-automate/src/project/run.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@ import { join } from 'path';
33

44
import yaml from 'yaml';
55

6-
import { getChromePath } from '../../utils';
6+
import { getChromePath } from '@guardoni/guardoni/utils';
77

8-
import {
9-
generateDirectoryStructure,
10-
} from '@project/init';
8+
import { generateDirectoryStructure } from '@project/init';
119

1210
import { decodeOrThrow, rightOrThrow } from '@util/fp';
1311
import { fileExists } from '@util/fs';

platforms/tktrex/automation/tsconfig.json platforms/tt-automate/tsconfig.json

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"extends": "../../../tsconfig.json",
2+
"extends": "../../tsconfig.json",
33
"compilerOptions": {
44
"allowSyntheticDefaultImports": true,
55
"allowJs": true,
@@ -18,23 +18,23 @@
1818
"lib": ["ES2021"],
1919
"skipLibCheck": true,
2020
"paths": {
21-
"@shared/*": ["../../../../packages/shared/src/*"],
21+
"@shared/*": ["../../../packages/shared/src/*"],
2222
"@tktrex/*": ["../../shared/src/*"],
23-
"@guardoni/*": ["../../../../guardoni/src/*"],
23+
"@guardoni/*": ["../../guardoni/src/*"],
2424
"@experiment/*": ["./experiment/*"],
2525
"@experiment": ["./experiment/index"],
2626
"@project/*": ["./project/*"],
2727
"@project": ["./project/index"],
2828
"@storage/*": ["./storage/*"],
2929
"@util/*": ["./util/*"],
30-
"@TikTok/*": ["./platform/TikTok/*"]
30+
"@platform/*": ["./platform/*"]
3131
},
3232
"sourceMap": true
3333
},
3434
"references": [
35-
{ "path": "../../../packages/shared" },
36-
{ "path": "../shared" },
37-
{ "path": "../../guardoni" }
35+
{ "path": "../../packages/shared" },
36+
{ "path": "../tktrex/shared" },
37+
{ "path": "../guardoni" }
3838
],
3939
"ts-node": {
4040
"require": ["tsconfig-paths/register"],
+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import * as t from 'io-ts';
2+
import * as path from 'path';
3+
import { getConfig } from '../../packages/shared/src/webpack/config';
4+
import packageJson from './package.json';
5+
6+
process.env.VERSION = packageJson.version;
7+
8+
const { buildENV: env, ...config } = getConfig({
9+
cwd: __dirname,
10+
outputDir: path.resolve(__dirname, 'build'),
11+
env: t.strict({}),
12+
hot: false,
13+
target: 'node16',
14+
entry: {
15+
'cli': path.resolve(__dirname, 'src/index.ts'),
16+
},
17+
});
18+
19+
config.module?.rules?.push(
20+
{
21+
// this is a hack to get webpack to be able to bundle
22+
// puppeteer-extra, found here:
23+
// https://github.com/berstend/puppeteer-extra/issues/93
24+
// this also requires the TypeScript to emit import / export statements
25+
// i.e. ES6+ nodules to work
26+
test: /node_modules\/puppeteer-extra\/dist\/index\.esm\.js/,
27+
loader: 'string-replace-loader',
28+
options: {
29+
// match a require function call where the argument isn't a string
30+
// also capture the first character of the args so we can ignore it later
31+
search: 'require[(]([^\'"])',
32+
// replace the 'require(' with a '__non_webpack_require__(', meaning it will require the files at runtime
33+
// $1 grabs the first capture group from the regex, the one character we matched and don't want to lose
34+
replace: '__non_webpack_require__($1',
35+
flags: 'g',
36+
},
37+
},
38+
{
39+
// also part of the puppeteer-extra hack
40+
test: /\.js$/,
41+
use: 'unlazy-loader',
42+
},
43+
{
44+
// this is required by canvas, part of linkedom
45+
test: /\.node$/,
46+
use: 'node-loader',
47+
}
48+
);
49+
50+
export default [
51+
// guardoni TK cli
52+
{
53+
...config,
54+
output: {
55+
...config.output,
56+
libraryTarget: 'commonjs',
57+
},
58+
node: {
59+
__dirname: false,
60+
},
61+
devtool: 'source-map',
62+
},
63+
];

0 commit comments

Comments
 (0)