Skip to content

Commit

Permalink
Merge branch 'main' into validate
Browse files Browse the repository at this point in the history
  • Loading branch information
samestep committed Jul 18, 2023
2 parents 6f144ed + 498da5d commit 11485b6
Show file tree
Hide file tree
Showing 21 changed files with 2,764 additions and 1,464 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
*.tgz
*.vsix
/.cargo/
/packages/vscode/*.png
/packages/wasm/wbg/
/target/
bindings/
dist/
Expand Down
5 changes: 0 additions & 5 deletions .prettierignore

This file was deleted.

2 changes: 1 addition & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{}
{ "plugins": ["prettier-plugin-organize-imports"] }
8 changes: 2 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@

Make sure to have these tools installed:

- [curl][]
- [Git][]
- [Make][]
- [Rust][]
- [Node.js][] v16-v18
- [Yarn][] v1.x

## Setup

Expand Down Expand Up @@ -72,15 +70,15 @@ an Internet connection.
To develop the website locally:

```
make site-deps && yarn workspace @rose-lang/site dev
make site-deps && npm run --workspace=@rose-lang/site dev
```

Then open http://localhost:5173/ in your browser.

Or, if you want to host on your local network, e.g. to test on your phone:

```
make site-deps && yarn workspace @rose-lang/site dev --host
make site-deps && npm run --workspace=@rose-lang/site dev -- --host
```

Then open http://192.168.0.12:5173/ on your phone.
Expand All @@ -97,9 +95,7 @@ make vscode
Then `packages/vscode` will contain a `*.vsix` file that you can install in VS
Code by right-clicking it and clicking the **Install Extension VSIX** button.

[curl]: https://curl.se/
[git]: https://git-scm.com/downloads
[make]: https://en.wikipedia.org/wiki/Make_(software)
[node.js]: https://nodejs.org/en/download
[rust]: https://www.rust-lang.org/tools/install
[yarn]: https://classic.yarnpkg.com/lang/en/docs/install
30 changes: 15 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ test-rust:
### JavaScript

# fetch JavaScript dependencies
yarn:
yarn
npm:
npm i

# check Prettier formatting
prettier: yarn
prettier: npm
npx prettier --check .

# build `packages/`
Expand All @@ -56,37 +56,37 @@ test-js: test-core
## `packages/core`

# build
core: yarn wasm
yarn workspace rose build
core: npm wasm
npm run --workspace=rose build

# test
test-core: yarn wasm
yarn workspace rose test run --no-threads
test-core: npm wasm
npm run --workspace=rose test -- run --no-threads

## `packages/site`

site-deps: yarn core
site-deps: npm core

site: site-deps
yarn workspace @rose-lang/site build
npm run --workspace=@rose-lang/site build

## `packages/vscode`

# fetch encircled icon
packages/vscode/encircled-rose.png:
curl -O --output-dir packages/vscode https://github.com/rose-lang/rose-icons/raw/efcc218832d65970a47bed597ee11cecd3d1cc3c/png/encircled-rose.png
node fetch.js https://github.com/rose-lang/rose-icons/raw/efcc218832d65970a47bed597ee11cecd3d1cc3c/png/encircled-rose.png $@

# fetch plain icon
packages/vscode/plain-rose.png:
curl -O --output-dir packages/vscode https://github.com/rose-lang/rose-icons/raw/efcc218832d65970a47bed597ee11cecd3d1cc3c/png/plain-rose.png
node fetch.js https://github.com/rose-lang/rose-icons/raw/efcc218832d65970a47bed597ee11cecd3d1cc3c/png/plain-rose.png $@

# build
vscode: yarn packages/vscode/encircled-rose.png packages/vscode/plain-rose.png
yarn workspace rose-vscode build
vscode: npm packages/vscode/encircled-rose.png packages/vscode/plain-rose.png
npm run --workspace=rose-vscode build

## `packages/wasm`

# build
wasm: yarn bindings wbg
yarn workspace @rose-lang/wasm build
wasm: npm bindings wbg
npm run --workspace=@rose-lang/wasm build
node bindings.js
4 changes: 2 additions & 2 deletions bindings.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ for (const crate of crates) {

// Read all .ts files in the bindings directory
const files = (await fs.readdir(bindings_dir)).filter((f) =>
f.endsWith(".ts")
f.endsWith(".ts"),
);
for (const file of files) {
const tsfile = path.join(bindings_dir, file);
Expand All @@ -38,7 +38,7 @@ for (const crate of crates) {
// Write the updated content to the new location with .d.ts extension
await fs.writeFile(
path.join(dest_folder, `${base_name}.d.ts`),
prettier.format(updated_content, { parser: "typescript" })
await prettier.format(updated_content, { parser: "typescript" }),
);
}
}
24 changes: 24 additions & 0 deletions fetch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { createWriteStream } from "fs";
import https from "https";
import { pipeline } from "stream/promises";
import { fileURLToPath } from "url";

// extract command line arguments
const [fileUrl, outputPath] = process.argv.slice(2);

https
.get(fileUrl, async (response) => {
try {
await pipeline(
response,
createWriteStream(fileURLToPath(new URL(outputPath, import.meta.url))),
);
} catch (error) {
console.error(`Error fetching resource: ${error}`);
process.exit(1);
}
})
.on("error", (error) => {
console.error(`Error: ${error}`);
process.exit(1);
});
Loading

0 comments on commit 11485b6

Please sign in to comment.