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

Commit

Permalink
chore: move tt-automation to platforms folder (#544)
Browse files Browse the repository at this point in the history
  • Loading branch information
ascariandrea authored Jun 6, 2022
1 parent 3fae71e commit 0b4e14a
Show file tree
Hide file tree
Showing 146 changed files with 168 additions and 1,433 deletions.
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 removed .yarn/cache/csv-npm-6.0.5-5655dcf8d7-e6d501c15d.zip
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 removed .yarn/cache/ltgt-npm-2.2.1-443b5da86d-7e3874296f.zip
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.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"taboule": "yarn workspace @trex/taboule",
"shared": "yarn workspace @trex/shared",
"guardoni": "yarn workspace guardoni",
"tt-automate": "yarn workspace tt-automate",
"tk:docs": "yarn workspace @tktrex/docs",
"tk:shared": "yarn workspace @tktrex/shared",
"tk:backend": "yarn workspace @tktrex/backend",
Expand Down
9 changes: 1 addition & 8 deletions platforms/guardoni/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,10 @@
"postinstall": "electron-builder install-app-deps",
"prepack": "yarn build",
"check-stealth": "ts-node ./bin/check-stealth.ts",
"automate:dev": "ts-node ./src/tx-automate/index.ts",
"automate": "node dist/index.js",
"tdd": "jest --watch --verbose"
},
"bin": {
"cli": "./bin/guardoni-cli.js",
"tk-cli": "./bin/guardoni-tk-cli.js"
"cli": "./bin/guardoni-cli.js"
},
"main": "./build/electron/main.js",
"repository": {
Expand Down Expand Up @@ -70,8 +67,6 @@
"lodash": "^4.17.21",
"nconf": "^0.11.3",
"node-fetch": "^2.6.7",
"pouchdb-find": "^7.2.2",
"pouchdb-node": "^7.2.2",
"puppeteer-core": "^13.7.0",
"puppeteer-extra": "^3.2.3",
"puppeteer-extra-plugin-stealth": "^2.9.0",
Expand All @@ -89,8 +84,6 @@
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.7",
"@types/lodash": "^4.14.182",
"@types/nconf": "^0.10.2",
"@types/pouchdb-find": "^6.3.7",
"@types/pouchdb-node": "^6.1.4",
"@types/prettier": "^2.6.3",
"@types/react": "^17.0.45",
"@types/react-dom": "^17.0.17",
Expand Down
8 changes: 0 additions & 8 deletions platforms/guardoni/src/guardoni/tx-automate/config.ts

This file was deleted.

2 changes: 1 addition & 1 deletion platforms/guardoni/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"@tktrex/shared/*": ["../../tktrex/shared/src/*"]
}
},
"include": ["./src", "__mocks__", "__tests__"],
"include": ["./src", "__mocks__", "__tests__", "./typings"],
"exclude": ["node_modules", "build", "dist"],
"watchOptions": {
"watchFile": "useFsEvents",
Expand Down
54 changes: 0 additions & 54 deletions platforms/guardoni/webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,48 +162,6 @@ guardoniConfig.module?.rules?.push(
}
);

const { buildENV: guardoniTkBuildEnv, ...guardoniTKConfig } = getConfig({
cwd: __dirname,
outputDir: path.resolve(__dirname, 'build/guardoni'),
env: t.strict({}),
hot: false,
target: 'node16',
entry: {
'tk-cli': path.resolve(__dirname, 'src/guardoni/tx-automate/index.ts'),
},
});

guardoniTKConfig.module?.rules?.push(
{
// this is a hack to get webpack to be able to bundle
// puppeteer-extra, found here:
// https://github.com/berstend/puppeteer-extra/issues/93
// this also requires the TypeScript to emit import / export statements
// i.e. ES6+ nodules to work
test: /node_modules\/puppeteer-extra\/dist\/index\.esm\.js/,
loader: 'string-replace-loader',
options: {
// match a require function call where the argument isn't a string
// also capture the first character of the args so we can ignore it later
search: 'require[(]([^\'"])',
// replace the 'require(' with a '__non_webpack_require__(', meaning it will require the files at runtime
// $1 grabs the first capture group from the regex, the one character we matched and don't want to lose
replace: '__non_webpack_require__($1',
flags: 'g',
},
},
{
// also part of the puppeteer-extra hack
test: /\.js$/,
use: 'unlazy-loader',
},
{
// this is required by canvas, part of linkedom
test: /\.node$/,
use: 'node-loader',
}
);

export default [
{
...rendererConfig,
Expand All @@ -226,16 +184,4 @@ export default [
},
devtool: 'source-map',
},
// guardoni TK cli
{
...guardoniTKConfig,
output: {
...guardoniTKConfig.output,
libraryTarget: 'commonjs',
},
node: {
__dirname: false,
},
devtool: 'source-map',
},
];
8 changes: 0 additions & 8 deletions platforms/tktrex/automation/.vscode/settings.json

This file was deleted.

65 changes: 0 additions & 65 deletions platforms/tktrex/automation/webpack.config.ts

This file was deleted.

File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

/* eslint-disable no-console */

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

cli.parse();
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@trex/tt-automation",
"name": "tt-automate",
"version": "2.5.4",
"packageManager": "[email protected]",
"engines": {
Expand All @@ -14,6 +14,9 @@
"test": "jest --verbose",
"tdd": "jest --watch --verbose"
},
"bin": {
"cli": "./bin/cli.js"
},
"main": "./dist/index.js",
"devDependencies": {
"@types/node": "^16.11.36",
Expand Down
11 changes: 11 additions & 0 deletions platforms/tt-automate/src/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import * as t from 'io-ts';

export const MinimalProjectConfig = t.type(
{
experimentType: t.string,
useStealth: t.boolean,
proxy: t.union([t.null, t.string]),
},
'MinimalProjectConfig'
);
export type MinimalProjectConfig = t.TypeOf<typeof MinimalProjectConfig>;
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ import { MinimalProjectConfig } from '../../../config';
import { ExperimentDescriptor } from '@experiment/index';
import { decodeOrThrow } from '@util/fp';
import { sleep } from '@util/misc';
import { createHandleCaptcha, ensureLoggedIn } from '@platform/TikTok/util/page';
import {
createHandleCaptcha,
ensureLoggedIn,
} from '@platform/TikTok/util/page';
import { parseSearchTop } from '@platform/TikTok/parser/index';
import { loadQueriesCSV } from '@util/csv';
import { fillInput } from '@util/page';
Expand All @@ -18,8 +21,6 @@ import {
confirmPublicKeyNoted,
} from '@platform/TikTok/util/project';



const Config = t.intersection(
[
MinimalProjectConfig,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import { shellEscape } from '@util/misc';
import { createLogger } from '@util/logger';
import experimentDescriptors from '@experiment/descriptors';



export const generateDirectoryStructure = (
projectDirectory: string
): Record<string, string> => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ import { join } from 'path';

import yaml from 'yaml';

import { getChromePath } from '../../utils';
import { getChromePath } from '@guardoni/guardoni/utils';

import {
generateDirectoryStructure,
} from '@project/init';
import { generateDirectoryStructure } from '@project/init';

import { decodeOrThrow, rightOrThrow } from '@util/fp';
import { fileExists } from '@util/fs';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../tsconfig.json",
"extends": "../../tsconfig.json",
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"allowJs": true,
Expand All @@ -18,23 +18,23 @@
"lib": ["ES2021"],
"skipLibCheck": true,
"paths": {
"@shared/*": ["../../../../packages/shared/src/*"],
"@shared/*": ["../../../packages/shared/src/*"],
"@tktrex/*": ["../../shared/src/*"],
"@guardoni/*": ["../../../../guardoni/src/*"],
"@guardoni/*": ["../../guardoni/src/*"],
"@experiment/*": ["./experiment/*"],
"@experiment": ["./experiment/index"],
"@project/*": ["./project/*"],
"@project": ["./project/index"],
"@storage/*": ["./storage/*"],
"@util/*": ["./util/*"],
"@TikTok/*": ["./platform/TikTok/*"]
"@platform/*": ["./platform/*"]
},
"sourceMap": true
},
"references": [
{ "path": "../../../packages/shared" },
{ "path": "../shared" },
{ "path": "../../guardoni" }
{ "path": "../../packages/shared" },
{ "path": "../tktrex/shared" },
{ "path": "../guardoni" }
],
"ts-node": {
"require": ["tsconfig-paths/register"],
Expand Down
63 changes: 63 additions & 0 deletions platforms/tt-automate/webpack.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import * as t from 'io-ts';
import * as path from 'path';
import { getConfig } from '../../packages/shared/src/webpack/config';
import packageJson from './package.json';

process.env.VERSION = packageJson.version;

const { buildENV: env, ...config } = getConfig({
cwd: __dirname,
outputDir: path.resolve(__dirname, 'build'),
env: t.strict({}),
hot: false,
target: 'node16',
entry: {
'cli': path.resolve(__dirname, 'src/index.ts'),
},
});

config.module?.rules?.push(
{
// this is a hack to get webpack to be able to bundle
// puppeteer-extra, found here:
// https://github.com/berstend/puppeteer-extra/issues/93
// this also requires the TypeScript to emit import / export statements
// i.e. ES6+ nodules to work
test: /node_modules\/puppeteer-extra\/dist\/index\.esm\.js/,
loader: 'string-replace-loader',
options: {
// match a require function call where the argument isn't a string
// also capture the first character of the args so we can ignore it later
search: 'require[(]([^\'"])',
// replace the 'require(' with a '__non_webpack_require__(', meaning it will require the files at runtime
// $1 grabs the first capture group from the regex, the one character we matched and don't want to lose
replace: '__non_webpack_require__($1',
flags: 'g',
},
},
{
// also part of the puppeteer-extra hack
test: /\.js$/,
use: 'unlazy-loader',
},
{
// this is required by canvas, part of linkedom
test: /\.node$/,
use: 'node-loader',
}
);

export default [
// guardoni TK cli
{
...config,
output: {
...config.output,
libraryTarget: 'commonjs',
},
node: {
__dirname: false,
},
devtool: 'source-map',
},
];
Loading

0 comments on commit 0b4e14a

Please sign in to comment.