You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: CONTRIBUTING.md
+8
Original file line number
Diff line number
Diff line change
@@ -1,14 +1,17 @@
1
1
# Contributing Guide
2
+
2
3
If you get stuck, message me on discord `@samualn`.
3
4
4
5
## Requirements
6
+
5
7
-[Git](https://git-scm.com/)
6
8
-**Windows:** Make sure you install Git Bash with it
7
9
-[Clone this repository](https://docs.github.com/en/repositories/creating-and-managing-repositories/cloning-a-repository)
8
10
-[PNPM](https://pnpm.io/)
9
11
-**Optional:**[`direnv`](https://direnv.net/)
10
12
11
13
## Linux Users
14
+
12
15
1. Open this cloned repository in a terminal
13
16
2. Run `pnpm install`
14
17
3. Modify your `PATH`
@@ -17,21 +20,26 @@ If you get stuck, message me on discord `@samualn`.
17
20
4. Run `scripts/package.sh` to compile everything and build the NPM package in `dist`
18
21
19
22
## Windows Users
23
+
20
24
1. Open this cloned repository in Git Bash
21
25
2. Run `pnpm install`
22
26
3. Run `export PATH=$PWD/node_modules/.bin:$PATH`
23
27
4. Run `scripts/package.sh` to compile everything and build the NPM package in `dist`
24
28
25
29
## Tips and Tricks
30
+
26
31
Run `./rollup.config.js` to only recompile.
27
32
28
33
### Run the Development Version of HSM
34
+
29
35
You can run the development version of HSM by running `node dist/bin/hsm.js`. You can pass it arguments just like you normally would e.g. `node dist/bin/hsm.js --version`.
30
36
31
37
### Install the Development Version of the NPM Package in Another Project
38
+
32
39
In the other project (e.g. testing with Hackmud Scripting Environment) run `pnpm add ~/path/to/hackmud-script-manager/dist`.
33
40
34
41
## Tests
42
+
35
43
Tests can be run by running `vitest run` (assuming you have followed above setup instructions).
36
44
37
45
There is currently not enforcement on writing unit tests but if you are going to, the test you write MUST be failing.
Command made for [Hackmud Scripting Environment](https://github.com/samualtnorman/hackmud-environment), which is a scripting environment for hackmud with minification, autocompletes / intellisense, and TypeScript support.
2. Name your source script file to `<name>.src.js`
17
20
3. Run `hsm minify <name>.src.js` and it will create a minified script file called `<name>.js`
18
21
19
22
> **NOTE:** If you get an error message that looks like this:
23
+
>
20
24
> ```
21
25
> [...]\AppData\Local\pnpm\hsm.ps1 cannot be loaded because running scripts is disabled on this system. [...]
22
26
> ```
27
+
>
23
28
> You will need to run `Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope CurrentUser` in PowerShell as an administrator. For more information, see [Microsoft's page about Execution Policies](https://learn.microsoft.com/en-gb/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-7.4).
- Supported types are null, numbers, strings, and JSON compatible objects and arrays.
33
-
- Non JSON compatible object keys are quine cheated.
34
-
- Member expressions are converted to index notation so the index string can be quine cheated.
35
-
- And template literals are converted to string concatenation so the strings can be quine cheated.
36
-
- Global variable aliasing.
37
-
- Convert function declarations to arrow function assigned to variable hoisted to the top of the block (`function foo() { ... }` -> `let foo = () => ...`).
38
-
- Convert `_START` and `_TIMEOUT` to `_ST` and `_TO`.
39
-
- Remove unused parameters from the main function expression.
37
+
- This includes auto quine cheating.
38
+
- Supported types are null, numbers, strings, and JSON compatible objects and arrays.
39
+
- Non JSON compatible object keys are quine cheated.
40
+
- Member expressions are converted to index notation so the index string can be quine cheated.
41
+
- And template literals are converted to string concatenation so the strings can be quine cheated.
42
+
- Global variable aliasing.
43
+
- Convert function declarations to arrow function assigned to variable hoisted to the top of the block (`function foo() { ... }` -> `let foo = () => ...`).
44
+
- Convert `_START` and `_TIMEOUT` to `_ST` and `_TO`.
45
+
- Remove unused parameters from the main function expression.
- Bigint literals are converted to `BigInt()` calls.
49
+
- Hackmud already supports all modern regular expression features.
44
50
- Future JavaScript Syntax and Features
45
-
- Warning: TypeScript doesn't support any of these features and these features may change or not actually make it into JavaScript.
46
-
- [Decorators](https://babeljs.io/docs/en/babel-plugin-proposal-decorators), [Do Expressions](https://babeljs.io/docs/en/babel-plugin-proposal-do-expressions), [Function Bind](https://babeljs.io/docs/en/babel-plugin-proposal-function-bind), [Function Sent](https://babeljs.io/docs/en/babel-plugin-proposal-function-sent), [Partial Application](https://babeljs.io/docs/en/babel-plugin-proposal-partial-application), [Pipeline Operator](https://babeljs.io/docs/en/babel-plugin-proposal-pipeline-operator) (using the hack proposal and `%` as the topic token), [Throw Expression](https://babeljs.io/docs/en/babel-plugin-proposal-throw-expressions), [Record and Tuple](https://babeljs.io/docs/en/babel-plugin-proposal-record-and-tuple) (hash `#` syntax type).
51
+
- Warning: TypeScript doesn't support any of these features and these features may change or not actually make it into JavaScript.
52
+
- [Decorators](https://babeljs.io/docs/en/babel-plugin-proposal-decorators), [Do Expressions](https://babeljs.io/docs/en/babel-plugin-proposal-do-expressions), [Function Bind](https://babeljs.io/docs/en/babel-plugin-proposal-function-bind), [Function Sent](https://babeljs.io/docs/en/babel-plugin-proposal-function-sent), [Partial Application](https://babeljs.io/docs/en/babel-plugin-proposal-partial-application), [Pipeline Operator](https://babeljs.io/docs/en/babel-plugin-proposal-pipeline-operator) (using the hack proposal and `%` as the topic token), [Throw Expression](https://babeljs.io/docs/en/babel-plugin-proposal-throw-expressions), [Record and Tuple](https://babeljs.io/docs/en/babel-plugin-proposal-record-and-tuple) (hash `#` syntax type).
47
53
- TypeScript Support
48
-
- This command/module does **not** do type checking, it simply removes type annotations so you'll need to rely on your IDE or run `tsc` seperatly with `noEmit`.
54
+
- This command/module does **not** do type checking, it simply removes type annotations so you'll need to rely on your IDE or run `tsc` seperatly with `noEmit`.
49
55
- And “Cool” Unnecessary Features.
50
-
- Variables declared outside the main function expression automatically become `#G` global variables.
51
-
- Any code outside the function expression will only run once per top level script execution (`#FMCL`).
52
-
- Basic seclevel verification.
53
-
- Declaring `// @seclevel HIGHSEC` or any other seclevel before all of your code stops you from accidentally using `#ls.` or `#ns.`.
54
-
- Import `node_modules` modules into your script using `import { foo } from "bar"` syntax.
55
-
- `_SOURCE` is replaced with a string of the source code of the script it's in.
56
-
- `_BUILD_DATE` is replaced with a unix timestamp (`Date.now()`) of the build date of the script.
57
-
- `_SCRIPT_USER` is replaced with a string of the user the script was pushed to.
58
-
- This saves characters compared to `context.this_script.split(".")[0]`.
59
-
- `_SCRIPT_SUBNAME` is like `_SCRIPT_USER` but for the name of the script.
60
-
- Saves characters compared to `context.this_script.split(".")[1]`.
61
-
- `_FULL_SCRIPT_NAME` is replaced with what would be in `context.this_script`.
62
-
- Subscript and `#db` methods names are verified.
63
-
- All references to preprocessor syntax functions not being called are turned into arrow function wrappers e.g. `let debug = #D;` -> `let debug = v => #D(v);`.
64
-
- `_SECLEVEL` is replaced with a number (`0` to `4`) representing the seclevel of the script.
56
+
- Variables declared outside the main function expression automatically become `#G` global variables.
57
+
- Any code outside the function expression will only run once per top level script execution (`#FMCL`).
58
+
- Basic seclevel verification.
59
+
- Declaring `// @seclevel HIGHSEC` or any other seclevel before all of your code stops you from accidentally using `#ls.` or `#ns.`.
60
+
- Import `node_modules` modules into your script using `import { foo } from "bar"` syntax.
61
+
- `_SOURCE` is replaced with a string of the source code of the script it's in.
62
+
- `_BUILD_DATE` is replaced with a unix timestamp (`Date.now()`) of the build date of the script.
63
+
- `_SCRIPT_USER` is replaced with a string of the user the script was pushed to.
64
+
- This saves characters compared to `context.this_script.split(".")[0]`.
65
+
- `_SCRIPT_SUBNAME` is like `_SCRIPT_USER` but for the name of the script.
66
+
- Saves characters compared to `context.this_script.split(".")[1]`.
67
+
- `_FULL_SCRIPT_NAME` is replaced with what would be in `context.this_script`.
68
+
- Subscript and `#db` methods names are verified.
69
+
- All references to preprocessor syntax functions not being called are turned into arrow function wrappers e.g. `let debug = #D;` -> `let debug = v => #D(v);`.
70
+
- `_SECLEVEL` is replaced with a number (`0` to `4`) representing the seclevel of the script.
65
71
- And Neat Weird Fixes
66
-
- Like `.__proto__` and `.prototype` being converted to `["__proto__"]` and `["prototype"]`.
67
-
- Illegal and unsafe strings.
68
-
- Appearences of `_SC` and friends are either renamed or have an escape inserted so that script is legal.
69
-
- Preprocessor syntax in strings are escaped so hackmud doesn't recognise them as preprocessor syntax.
70
-
- And appearences of `//` in strings and regexes have a backslash inserted between to stop hackmud's overagressive comment remover from removing half the line of code.
71
-
- Classes are actually usable now, this module replaces instances of `this` with a variable referencing what would be `this`.
72
-
- `Function.prototype` can be referenced (but only the `.prototype` property, nothing else).
73
-
- `Object.getPrototypeOf` and `Object.setPrototypeOf` are replaced with equivalent functions.
72
+
- Like `.__proto__` and `.prototype` being converted to `["__proto__"]` and `["prototype"]`.
73
+
- Illegal and unsafe strings.
74
+
- Appearences of `_SC` and friends are either renamed or have an escape inserted so that script is legal.
75
+
- Preprocessor syntax in strings are escaped so hackmud doesn't recognise them as preprocessor syntax.
76
+
- And appearences of `//` in strings and regexes have a backslash inserted between to stop hackmud's overagressive comment remover from removing half the line of code.
77
+
- Classes are actually usable now, this module replaces instances of `this` with a variable referencing what would be `this`.
78
+
- `Function.prototype` can be referenced (but only the `.prototype` property, nothing else).
79
+
- `Object.getPrototypeOf` and `Object.setPrototypeOf` are replaced with equivalent functions.
0 commit comments