Skip to content

Commit b816619

Browse files
Create darklua website (!37)
1 parent 65d8292 commit b816619

Some content is hidden

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

63 files changed

+26245
-209
lines changed

.gitattributes

+5
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
11
* text eol=lf
2+
3+
*.gif binary
4+
*.ico binary
5+
*.jpg binary
6+
*.png binary

.gitlab-ci.yml

+156-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
1-
image: 'rust:latest'
1+
image: "rust:latest"
22

33
cache:
44
paths:
55
- cargo/
6+
- site/node_modules/
67

78
stages:
9+
- install
810
- checks
11+
- pre-build
912
- build
1013
- test
1114
- integration-test
15+
- deploy
1216

1317
variables:
1418
CARGO_HOME: $CI_PROJECT_DIR/cargo
@@ -18,6 +22,100 @@ variables:
1822
- main
1923
- merge_requests
2024

25+
npm-install-site:
26+
image: node:16
27+
stage: install
28+
extends: .only-mr-and-main
29+
script:
30+
- cd site
31+
- npm install
32+
cache:
33+
key: node-modules-cache
34+
paths:
35+
- site/node_modules/
36+
policy: push
37+
needs: []
38+
39+
npm-install-wasm-tests:
40+
image: node:16
41+
stage: install
42+
extends: .only-mr-and-main
43+
script:
44+
- cd site/darklua-wasm/javascript-tests
45+
- npm install
46+
cache:
47+
key: node-modules-tests-cache
48+
paths:
49+
- site/darklua-wasm/javascript-tests/node_modules/
50+
policy: push
51+
needs: []
52+
53+
install-wasm-pack:
54+
stage: install
55+
extends: .only-mr-and-main
56+
script:
57+
- cargo install wasm-pack --version 0.9.1 # https://github.com/rustwasm/wasm-pack/issues/823
58+
cache:
59+
key: wasm-pack-install
60+
paths:
61+
- $CARGO_HOME/bin/wasm-pack
62+
policy: push
63+
needs: []
64+
65+
darklua-wasm-build-nodejs:
66+
stage: pre-build
67+
extends: .only-mr-and-main
68+
script:
69+
- $CARGO_HOME/bin/wasm-pack -V
70+
- $CARGO_HOME/bin/wasm-pack build site/darklua-wasm -t nodejs
71+
- mv site/darklua-wasm/pkg site/darklua-wasm/pkg-nodejs
72+
cache:
73+
key: wasm-pack-install
74+
paths:
75+
- $CARGO_HOME/bin/wasm-pack
76+
policy: pull
77+
artifacts:
78+
expire_in: 1 hour
79+
paths:
80+
- site/darklua-wasm/pkg-nodejs
81+
needs:
82+
- install-wasm-pack
83+
84+
darklua-wasm-build-release:
85+
stage: pre-build
86+
extends: .only-mr-and-main
87+
script:
88+
- $CARGO_HOME/bin/wasm-pack -V
89+
- $CARGO_HOME/bin/wasm-pack build site/darklua-wasm -t bundler --release
90+
cache:
91+
key: wasm-pack-install
92+
paths:
93+
- $CARGO_HOME/bin/wasm-pack
94+
policy: pull
95+
artifacts:
96+
expire_in: 1 hour
97+
paths:
98+
- site/darklua-wasm/pkg
99+
needs:
100+
- install-wasm-pack
101+
102+
wasm-javascript-tests:
103+
image: node:16
104+
stage: test
105+
extends: .only-mr-and-main
106+
script:
107+
- mv site/darklua-wasm/pkg-nodejs site/darklua-wasm/pkg
108+
- cd site/darklua-wasm/javascript-tests
109+
- npm run test
110+
cache:
111+
key: node-modules-tests-cache
112+
paths:
113+
- site/darklua-wasm/javascript-tests/node_modules/
114+
policy: pull
115+
needs:
116+
- npm-install-wasm-tests
117+
- darklua-wasm-build-nodejs
118+
21119
style-check:
22120
stage: checks
23121
extends: .only-mr-and-main
@@ -26,6 +124,7 @@ style-check:
26124
- rustup component add rustfmt
27125
- cargo fmt -- --version
28126
- cargo fmt -- --check
127+
needs: []
29128

30129
clippy:
31130
stage: checks
@@ -35,6 +134,22 @@ clippy:
35134
- rustup component add clippy
36135
- cargo clippy --version
37136
- cargo clippy --all-targets --all-features -- -D warnings
137+
needs: []
138+
139+
style-check-site:
140+
image: node:16
141+
stage: checks
142+
extends: .only-mr-and-main
143+
script:
144+
- cd site
145+
- npm run style-check
146+
cache:
147+
key: node-modules-cache
148+
paths:
149+
- site/node_modules/
150+
policy: pull
151+
needs:
152+
- npm-install-site
38153

39154
build:
40155
stage: build
@@ -48,6 +163,7 @@ build:
48163
paths:
49164
- cargo/
50165
- target/
166+
needs: []
51167

52168
build-release:
53169
stage: build
@@ -61,13 +177,49 @@ build-release:
61177
paths:
62178
- cargo/
63179
- target/
180+
needs:
181+
- clippy
182+
- style-check
183+
184+
build-site:
185+
image: node:16
186+
stage: build
187+
extends: .only-mr-and-main
188+
script:
189+
- cd site
190+
- npx gatsby --version
191+
- npx gatsby build
192+
cache:
193+
key: node-modules-cache
194+
paths:
195+
- site/node_modules/
196+
policy: pull
197+
artifacts:
198+
paths:
199+
- site/public
200+
needs:
201+
- npm-install-site
202+
- darklua-wasm-build-release
203+
204+
pages:
205+
stage: deploy
206+
script:
207+
- mv site/public public
208+
artifacts:
209+
paths:
210+
- public
211+
only:
212+
- main
213+
needs:
214+
- build-site
64215

65216
test:
66217
stage: test
67218
extends: .only-mr-and-main
68219
script:
69220
- cargo test --locked --verbose
70-
needs: ['build']
221+
needs:
222+
- build
71223

72224
.lua-setup:
73225
before_script:
@@ -86,4 +238,5 @@ test-lua-projects:
86238
- .lua-setup
87239
script:
88240
- lua ./scripts/test-commands.lua
89-
needs: ['build-release']
241+
needs:
242+
- build-release

Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ edition = "2018"
66
readme = "README.md"
77
description = "Transform Lua scripts"
88
repository = "https://gitlab.com/seaofvoices/darklua"
9+
homepage = "https://darklua.com"
910
license = "MIT"
1011
keywords = ["lua", "obsfucation", "minify"]
12+
exclude = ["site"]
1113

1214
[badges]
1315
gitlab = { repository = "seaofvoices/darklua" }

README.md

+5-125
Original file line numberDiff line numberDiff line change
@@ -4,135 +4,15 @@
44

55
# darklua
66

7-
Transform Lua 5.1 and Roblox Lua scripts using [rules](RULES.md).
7+
Transform Lua 5.1 and Roblox Lua scripts using rules.
88

9+
# [Documentation](https://darklua.com/docs)
910

10-
# Installation
11-
darklua is a command line tool that can be installed using [cargo](https://doc.rust-lang.org/cargo/getting-started/installation.html).
11+
Visit https://darklua.com/docs to learn how to use darklua.
1212

13-
```
14-
cargo install darklua
15-
```
16-
17-
If you want to use the lastest darklua available, install it using the git url:
18-
19-
```
20-
cargo install --git https://gitlab.com/seaofvoices/darklua.git
21-
```
22-
23-
24-
# Usage
25-
The following section will detail the different commands of darklua. You can also get a list of the available commands and options using the command line tool itself, simply run:
26-
```
27-
darklua help
28-
```
29-
To get help on a specific command, simply append `--help` (or `-h`) to the command name. For example, to get help on the `minify` command:
30-
```
31-
darklua minify --help
32-
```
33-
34-
## Process
35-
The process command is similar to the minify command: it takes an input path and generates code at the output path. This command will apply [rules](RULES.md) (the default rules or the one given in the configuration file) to each Lua file.
36-
37-
```
38-
darklua process <input-path> <output-path>
39-
40-
optional arguments:
41-
-c, --config-path <path>
42-
Path to a configuration file
43-
```
44-
45-
### Example
46-
If you have a `src` folder that contains a bunch of Lua scripts (files ending with `.lua`), you can process all the files with the default configuration (or with the configuration file located in the same folder where you are running the command) into a new folder called `processed-src` using the following command:
47-
48-
```
49-
darklua process src processed-src
50-
```
51-
52-
If a configuration file is found in the folder where the command is run, darklua will automatically use it. If your configuration file is not named `.darklua.json` or `.darklua.json5`, or not located in the folder where you are running the command, you must specify it with the `--config-path` argument:
53-
54-
```
55-
darklua process src processed-src --config-path ./path/config.json
56-
# or the shorter version:
57-
darklua process src processed-src -c ./path/config.json
58-
```
59-
60-
## Minify
61-
This command reads Lua code and reformats it to reduce the size of the code, measured in total bytes. The input path can be a single file name or a directory name. Given a directory, darklua will find all Lua files under that directory and output them following the same hierarchy.
62-
63-
```
64-
darklua minify <input-path> <output-path>
65-
66-
optional arguments:
67-
-c, --config-path <path>
68-
Path to a configuration file
69-
```
70-
71-
### Example
72-
If you have a `src` folder that contains a bunch of Lua scripts (files ending with `.lua`), you can generate the minified version of these Lua scripts into a new folder called `minified-src` using the following command:
73-
74-
```
75-
darklua minify src minified-src
76-
```
77-
78-
To specify the configuration file location, simply run:
79-
80-
```
81-
darklua minify src minified-src --config-path ./path/config.json
82-
# or the shorter version:
83-
darklua minify src minified-src -c ./path/config.json
84-
```
85-
86-
87-
# Configuration file
88-
Some commands can be modified using the configuration file. darklua supports both configuration file written in the json or json5 standard file formats. When running darklua, if the directory in which the `darklua` command is executed contains a file named `.darklua.json` or `.darklua.json5`, it will automatically read the file to get the configuration values unless the `--config-path` option is given to override it.
89-
90-
Any missing field will be replaced with its default value.
91-
92-
```json5
93-
{
94-
// when outputting code, darklua will wrap the code on a new line after
95-
// this amount of characters.
96-
column_span: 80,
97-
// put the rules that you want to execute when calling the process command.
98-
// If you do not provide this field, the default list of rules is going to
99-
// be executed.
100-
process: ["remove_empty_do"],
101-
}
102-
```
103-
104-
## Rule format
105-
Rules can be written in two different formats: The shortest format consists of simply providing the rule name. Using this format, the default rule properties will be used.
106-
107-
```json
108-
"remove_empty_do"
109-
```
110-
111-
If a rule can be configured with properties (specific values that tweak the behavior of the rule), the table format can be used to override each properties. The rule name **must** be specified with a field named `rule`. Then, simply enumerate the property name associated with its value.
112-
113-
```json5
114-
{
115-
rule: "the_rule_name",
116-
my_property_name: 50
117-
}
118-
```
119-
120-
For example, the two following examples define two configuration files that will execute the same rule, but written in the two different formats.
121-
122-
```json5
123-
{
124-
process: ["remove_empty_do"],
125-
}
126-
```
127-
128-
```json5
129-
{
130-
process: [{ rule: "remove_empty_do" }],
131-
}
132-
```
133-
134-
Information on the built-in rules and their configuration properties can be found [here](RULES.md).
13+
# [Try It!](https://darklua.com/try-it)
13514

15+
You can try darklua directly into your browser! Check out https://darklua.com/try-it.
13616

13717
# License
13818

0 commit comments

Comments
 (0)