Skip to content

Commit

Permalink
Merge pull request #25 from j4k0xb/monorepo
Browse files Browse the repository at this point in the history
  • Loading branch information
j4k0xb authored Dec 17, 2023
2 parents 331eaaa + 7f0c1cf commit 148f78d
Show file tree
Hide file tree
Showing 238 changed files with 10,320 additions and 10,522 deletions.
41 changes: 0 additions & 41 deletions .eslintrc

This file was deleted.

6 changes: 6 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/** @type {import("eslint").Linter.Config} */
module.exports = {
root: true,
extends: ["@webcrack/eslint-config/index.js"],
ignorePaths: ["vitest.config.ts"],
};
33 changes: 33 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: CI

on:
push:
branches: [master]
pull_request:

jobs:
build:
name: Build and Test
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2
- uses: actions/setup-node@v3
with:
node-version: "18.x"
cache: "pnpm"

- name: Install dependencies
run: pnpm install

- name: Lint
run: pnpm lint

- name: Test
run: pnpm test
26 changes: 11 additions & 15 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,24 @@ on:
jobs:
build:
runs-on: ubuntu-latest
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2
- uses: actions/setup-node@v3
with:
node-version: '18.x'
registry-url: 'https://registry.npmjs.org'

- name: Cache node modules
id: nodemodules-cache
uses: actions/cache@v3
with:
path: node_modules
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/package-lock.json') }}
node-version: "18.x"
cache: "pnpm"

- name: Install dependencies
if: steps.nodemodules-cache.outputs.cache-hit != 'true'
run: npm ci
run: pnpm install

- name: build
run: npm run build
- name: Build
run: pnpm build --filter webcrack

- name: Publish package
run: npm publish
- name: Publish
run: pnpm publish --filter webcrack
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
36 changes: 0 additions & 36 deletions .github/workflows/test.yml

This file was deleted.

14 changes: 12 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
.DS_Store
node_modules
.turbo
*.log
dist
tmp
.vscode/settings.json
dist-ssr
*.local
.env
.cache
server/dist
public/dist
**/.vitepress/dist/**
**/.vitepress/cache/**
coverage
.netlify
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
auto-install-peers = true
3 changes: 3 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"singleQuote": true
}
8 changes: 4 additions & 4 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"runtimeExecutable": "npm",
"name": "Deobfuscate tmp file",
"runtimeExecutable": "pnpm",
"runtimeArgs": [
"run",
"dev"
"tmp"
],
"cwd": "${workspaceFolder}/tmp",
"cwd": "${workspaceFolder}/packages/webcrack",
"outputCapture": "std",
"skipFiles": [
"<node_internals>/**"
Expand Down
7 changes: 7 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"eslint.workingDirectories": [
{
"mode": "auto"
}
]
}
40 changes: 20 additions & 20 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,44 @@

You can directly create a PR if the change is small. Otherwise, please open an issue first to discuss the change.

The `package.json` version shouldn't be changed.

## Getting Started

This project uses [pnpm](https://pnpm.js.org/) for package management. Please make sure you have it installed before proceeding.

1. Fork and clone the repo
2. Check out a new branch: `git checkout -b some-feature`
3. Install dependencies: `npm install`
3. Install dependencies: `pnpm install`
4. Test your changes in the playground: `pnpm dev`

## Debugging
## Attach a Debugger

1. Create a directory named `tmp` with `test.js` inside and paste your code
2. Press `F5` in VSCode to build the project and launch the debugger (or run `npm run dev`)
1. Create the file `packages/webcrack/tmp/test.js` and paste your code
2. Press `F5` in VSCode to build the project and launch the debugger

The output will be saved in `tmp/webcrack-out`.

## Tests

Run the tests in watch mode with `npm test` (or use the [Vitest](https://marketplace.visualstudio.com/items?itemName=ZixuanChen.vitest-explorer) vscode extension).
Run the tests with `pnpm test`.

If the snapshots are outdated, make sure the changes are correct and update them:
`.toMatchInlineSnapshot()` for new tests will automatically generate the expected output when saved, no need to write it manually.

If the snapshots are outdated, make sure the changes are correct and update them:
![failed snapshot](https://user-images.githubusercontent.com/55899582/219093007-825a5056-38a0-4e8b-8512-b56e20174885.png)

### Types of tests

- Transforms: add tests in [transforms.test.ts](test/transforms.test.ts)
- Deobfuscator or bundle unpacker: create/modify a [sample script](test/samples)
- Public JS API: add tests in [api.test.ts](test/api.test.ts)
## Linting and Formatting

The samples should be as small as possible, but still representative.
```bash
pnpm lint:fix && pnpm format
```

## Create a new transform
## Create a new Transform

The easiest way to create a new transform is to copy an existing one and modify it.

## Performance Optimizations

### Named visitor keys
### Named Visitor Keys

```diff
{
Expand All @@ -48,7 +48,7 @@ The easiest way to create a new transform is to copy an existing one and modify
}
```

### `noScope` visitors
### `noScope` Visitors

May not work in some cases (accessing `path.scope` when the scope hasn't been crawled before).

Expand All @@ -59,7 +59,7 @@ May not work in some cases (accessing `path.scope` when the scope hasn't been cr
}
```

### Merging visitors
### Merging Visitors

To only traverse the AST once and avoid missing nodes based on the order of visitors.

Expand All @@ -69,7 +69,7 @@ To only traverse the AST once and avoid missing nodes based on the order of visi
+ applyTransforms(ast, [transformA, transformB]);
```

### Renaming bindings (variables, functions, ...)
### Renaming Bindings (variables, functions, ...)

This also avoids conflicts by first renaming bindings with the name `b` to something else.

Expand All @@ -79,7 +79,7 @@ This also avoids conflicts by first renaming bindings with the name `b` to somet
+ renameFast(binding, 'b');
```

### Following references instead of traversing the AST
### Following References instead of Traversing the AST

For example finding calls to a function `foo` (provided that you already have foo's NodePath):

Expand Down
21 changes: 0 additions & 21 deletions LICENSE

This file was deleted.

17 changes: 17 additions & 0 deletions apps/docs/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "docs",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vitepress dev src",
"build": "vitepress build src",
"preview": "vitepress preview"
},
"devDependencies": {
"@webcrack/eslint-config": "workspace:*",
"@webcrack/typescript-config": "workspace:*",
"typescript": "^5.3.2",
"vitepress": "1.0.0-rc.31"
}
}
Loading

0 comments on commit 148f78d

Please sign in to comment.