Skip to content

Commit e8b7ea1

Browse files
committed
Update libs and docs about focused installations
1 parent c0a6137 commit e8b7ea1

File tree

81 files changed

+734
-142
lines changed

Some content is hidden

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

81 files changed

+734
-142
lines changed

docs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"scripts": {
88
"build": "yarn build-lib-docs && vitepress build .",
99
"build-lib-docs": "yarn workspaces foreach -A --include \"@sourceacademy/modules-lib\" run docs",
10-
"dev": "node ./runner.js",
10+
"dev": "vitepress dev .",
1111
"postinstall": "yarn build-lib-docs",
1212
"preview": "vitepress preview ."
1313
},

docs/src/buildtools/1-devenv.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ yarn workspaces focus @sourceacademy/modules-buildtools
1717
Compiling the build tools is as simple as running `yarn build`. This by default produces a minified Javascript file, which is not very conducive to debugging. If necessary
1818
you can run `yarn build --dev` instead to produce a non-minified build.
1919

20-
For the projects that are supposed to be bundled into a single file using `esbuild`, the package `@sourceacademy/lib-compiler` wraps `esbuild` and `commander` to create a
21-
easy to use compiler.
20+
For the projects that are supposed to be bundled into a single file using `esbuild`, the package `@sourceacademy/modules-repotools` exports a function that
21+
wraps `esbuild` and `commander` to create a easy to use compiler.
2222

2323
## Testing
2424

docs/src/modules/1-getting-started/2-start.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,17 @@ This may prompt you to download the version of Yarn that this repository uses.
2525
>
2626
> `corepack enable` should automatically install the version of Yarn used by the repository, but if you face issues using `corepack`, you can still use `npm` to install Yarn. You will however, need to run
2727
> `yarn set version` to change to the correct version of Yarn before working with the repository.
28+
>
29+
> If that is the case, you must take care **not** to commit the `yarnPath` changes that will be made to the `.yarnrc.yml` file.
30+
31+
## 4. Install the root package's dependencies
32+
33+
Run the following command to ensure that dependencies like `eslint` get installed correctly:
34+
```sh
35+
yarn workspaces focus @sourceacademy/modules
36+
```
2837

29-
At this point it is not necessary to run `yarn install` yet to install dependencies. Depending on what you are doing, there are different methods for installing dependencies.
38+
At this point it is not necessary to run `yarn install` yet to install any other dependencies. Depending on what you are doing, there are different methods for installing dependencies.
3039

3140
## Next Steps
3241

docs/src/modules/1-getting-started/3-git.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,15 @@ When making changes to the code in this repository, you should abide by some goo
99
- Commit often with informative commit messages
1010
- Run the `pre-push` Git Hook before pushing so that your code is verified locally
1111

12+
> [!TIP] Lockfiles
13+
> Package managers such as `yarn` and `npm` use a single file called the lockfile to keep track of the dependencies and their dependencies and so on.
14+
> Since this repository uses Yarn, the lockfile we use is `yarn.lock`.
15+
>
16+
> There is always only one lockfile. Even if you use focused installs or add a dependency to a single package, `yarn.lock` will be modified.
17+
>
18+
> When you add a dependency to your bundle/tab, remember to run your installation command to ensure that the lockfile gets updated, and then
19+
> commit the changes to the lockfile.
20+
1221
## Creating your own branch
1322

1423
The `master` branch of the repository is protected. This means that you cannot push commits directly to it, nor can pull requests be merged

docs/src/modules/1-getting-started/4-cheat.md

Lines changed: 49 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,14 @@ All commands have a `-h` or `--help` option that can be used to get more informa
4040
</tbody>
4141
</table>
4242

43-
\* Will add packages to the root repository. Only do this if you are adding or updating a constraint for the entire repository.
43+
> [!WARNING] Adding Dependencies
44+
> `yarn add` will add the dependencies to the package whose directory this command is being run under. For example,
45+
> if you run `yarn add` from `src/bundles/curve`, then the dependencies get added to the curve bundle.
46+
>
47+
> However, if you run `yarn add` from the root of the repository, then the dependencies get added to the
48+
> `@sourceacademy/modules` package instead.
49+
>
50+
> Be careful of where you run this command so as to avoid extraneous dependencies being added to the wrong packages.
4451
4552
## Bundle or Tab Specific Commands
4653

@@ -62,7 +69,10 @@ These commands are only applicable to bundles or tabs and should only be run fro
6269
</tr>
6370
<tr>
6471
<td><nobr><code>yarn build --tsc</code></nobr></td>
65-
<td>Same as <code>yarn build</code> but also runs <code>tsc</code> for type checking</td>
72+
<td>
73+
Same as <code>yarn build</code> but also runs <code>tsc</code> for type checking. <br/>
74+
For bundles, this will also output the library form of the bundle
75+
</td>
6676
</tr>
6777
<tr>
6878
<td><nobr><code>yarn build --lint</code></nobr></td>
@@ -76,13 +86,36 @@ Both the `--tsc` and `--lint` options can be used togther to run `tsc` and ESLin
7686
### Prebuild and Testing
7787

7888
<ins>Prebuild</ins> refers to commands that are to be run **before** the build/compilation commands are executed.
79-
80-
| Command | Purpose |
81-
|---------------------------|---------------------------------------------------------------|
82-
| `yarn lint` | Run ESLint |
83-
| `yarn tsc` | Run `tsc` |
84-
| `yarn prebuild` | Run both ESLint and `tsc` without running any builds |
85-
| `yarn test` | Run any unit tests defined for the current bundle/tab |
89+
<table>
90+
<thead>
91+
<tr>
92+
<th>Command</th>
93+
<th>Purpose</th>
94+
</tr>
95+
</thead>
96+
<tbody>
97+
<tr>
98+
<td><code>yarn lint</code></td>
99+
<td>Run ESLint on the bundle's/tab's code</td>
100+
</tr>
101+
<tr>
102+
<td><code>yarn tsc</code></td>
103+
<td>Run the typescript compiler. For bundles, this will <br/> also output the library form of the bundle.</td>
104+
</tr>
105+
<tr>
106+
<td><code>yarn prebuild</code></td>
107+
<td>Run both ESLint and <code>tsc</code> <strong>without</strong> running any builds</td>
108+
</tr>
109+
<tr>
110+
<td><code>yarn test</code></td>
111+
<td>Run any unit tests defined for the bundle/tab</td>
112+
</tr>
113+
<tr>
114+
<td><code>yarn serve</code></td>
115+
<td>Start the modules server</td>
116+
</tr>
117+
</tbody>
118+
</table>
86119

87120
#### NOTES
88121

@@ -122,6 +155,13 @@ In general, global scripts for this repository follow the same format.
122155
- `:libs` will be run for all code under the `lib` folder (common modules libraries)
123156
- `:modules` will be run for all bundle and tab code
124157

158+
> [!WARNING] On Focused Installs
159+
> If you used a focus install, the dependencies for the other bundles and tabs will not be available. In fact, the root
160+
> repository's package may not have been installed either.
161+
>
162+
> This means that many of the `:all` and `:modules` commands will not work. You should use the bundle or tab specific
163+
> commands instead.
164+
125165
<table>
126166
<thead>
127167
<tr>

docs/src/modules/1-getting-started/6-troubleshooting.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,11 @@ You will need to delete the `node_modules` folder and rerun your installation co
1717
Especially if you've worked with other Javascript/Typescript projects before, you might find that `corepack enable` is a command that
1818
does not seem to work (or work permanently) for you.
1919

20+
For example, you might find that `corepack enable` has no effect and the version of Yarn being used is an incorrect version when you run commands.
21+
2022
Things to check for:
2123

2224
- Remove any errant `package.json` or `.yarnrc.yml` files in places like your home directory or elsewhere.
23-
- Run `npm uninstall -g yarn` if you previously installed Yarn using installed `npm`.
24-
- For people running Windows, `corepack enable` is a command that needs to be run using administrator privileges. If this is not possible for you, there are [workarounds](https://github.com/nodejs/corepack?tab=readme-ov-file#corepack-enable--name).
25+
- Run `npm uninstall -g yarn` if you previously installed Yarn globally using installed `npm`.
26+
- For people running Windows, `corepack enable` is a command that needs to be run using administrator privileges.
27+
If this is not possible for you, there are [workarounds](https://github.com/nodejs/corepack?tab=readme-ov-file#corepack-enable--name).

docs/src/modules/2-bundle/3-editing.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,17 @@ This adds the dependency to `devDependencies` instead.
4747
> yarn add @sourceacademy/modules-lib@workspace:^
4848
> ```
4949
50+
You can also add the dependency directly by modifying your `package.json`:
51+
```jsonc {4}
52+
{
53+
"name": "@sourceacademy/bundle-bundle0",
54+
"dependencies": {
55+
"lodash": "^4.0.0"
56+
}
57+
}
58+
```
59+
If you do so, remember to run your installation command (same as the one above) to update the lockfile.
60+
5061
### React Within bundles
5162
5263
Currently, the way bundles are loaded by `js-slang` means that React cannot be externalized for bundles. `js-slang` simply has no way to provide React

docs/src/modules/3-tabs/3-editing.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,17 @@ This adds the dependency to `devDependencies` instead.
4747
> yarn add @sourceacademy/modules-lib@workspace:^
4848
> ```
4949
50+
You can also add the dependency directly by modifying your `package.json`:
51+
```jsonc {4}
52+
{
53+
"name": "@sourceacademy/bundle-bundle0",
54+
"dependencies": {
55+
"lodash": "^4.0.0"
56+
}
57+
}
58+
```
59+
If you do so, remember to run your installation command (same as the one above) to update the lockfile.
60+
5061
## React/UI Components
5162
5263
Tabs are written using the React (JSX) syntax. In React, each UI element is referred to as a "component". Documentation on how to create UIs and use React can be found [here](https://react.dev). Where possible,

docs/src/modules/3-tabs/6-devserver/6-devserver.md

Lines changed: 0 additions & 37 deletions
This file was deleted.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Running from the Desktop
2+
3+
It is possible to run `js-slang` directly from the desktop using the `js-slang` command line. However, this is only really useful for bundles, as `js-slang` from
4+
the command line cannot display tabs.
5+
6+
You will need to change which module backend is in use using the `--modulesBackend` parameter.
7+
8+
If your package already depends on `js-slang`, then you can already run `js-slang` from the command line using `yarn js-slang`.
9+
10+
If not, you can either add `js-slang` to your dev dependencies, or you can install the root repository package.
11+
12+
## The Modules Server
13+
14+
All modules related files are served from a single HTTP server. For `js-slang` to be able to access your local modules copies, you will have to run a local version
15+
of this server and then point `js-slang` to it.
16+
17+
The `yarn buildtools serve` command will start a HTTP server and serve the `build` directory, which is where your bundle/tab should've been output to after compilation.
18+
19+
If need be, you can use the `--port` option or the `PORT` environment variable to change what port the server listens on, the default being 8022.
20+
21+
Similarly, `--bind` can be used to change which interface the server listens on.
22+
23+
> [!WARNING] On Focused Installs
24+
> The HTTP server is provided by the buildtools and thus is only available within packages that have installed the buildtools. If you used
25+
> a focused Yarn install, then the `serve` command is only available within your bundle's/tab's package.
26+
>
27+
> Using a focused install also means that other bundles and tabs are not available for use during your testing, as they will not be compiled.
28+
>
29+
> If the `serve` command is unavailable for whatever reason, you can install it with the root repository using
30+
> `yarn workspaces focus @sourceacademy/modules` and then run `yarn serve` from the root repository.

0 commit comments

Comments
 (0)