Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup release on CI when tag is pushed #8

Merged
merged 2 commits into from
Jul 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Release

on:
push:
tags:
- v*

env:
CARGO_TERM_COLOR: always

jobs:
release:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh

# remove scope or update it once we decide exactly where we want to deploy this thing
- run: wasm-pack build --target nodejs
- run: npm publish
working-directory: pkg
23 changes: 23 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Contributing

## Prerequisites

- You need to have rustup installed, and when you run `cargo build` or `cargo test` it will use the nightly rust version that is defined in `rust-toolchain` in the root of the repo.
- You need to run `rustup target add wasm32-unknown-unknown` to download this target for your system
- You need to install wasm-pack https://rustwasm.github.io/wasm-pack/

## Running

CLI:

`cargo run ./sample/component.gjs`

Tests:

`cargo test`:

Build wasm package:

`wasm-pack build --target=nodejs`

which will output your wasm package in `./pkg`
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
[package]
name = "content-tag"
description = "A rust program that uses a fork of swc to parse GJS and transpile to valid JS"
repository = "https://github.com/embroider-build/content-tag"
license = "MIT"
version = "0.1.0"
edition = "2021"

Expand Down
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Edward Faulkner

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
36 changes: 16 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,26 @@
# content-tag

## Prerequisites
`content-tag` is a preprocessor for JS files that are using the content-tag proposal. This originated with Ember.js' GJS and GTS functionality. You can read more by [checking out the original RFC](https://rfcs.emberjs.com/id/0931-template-compiler-api/)

- rust nightly via rustup (at time of writing I'm using rustc 1.71.0-nightly (f5559e338 2023-04-24))
- wasm-pack
- rustup target add wasm32-unknown-unknown
- you need to clone ef4/swc `content-tag` branch and have it located next to your clone of this repo
This preprocessor can be used to transform files using the `content-tag` spec to standard JS. It is built on top of [swc](https://swc.rs/) using Rust and is deployed as a wasm package.

## Running
## Installation

CLI:

`cargo run ./sample/component.gjs`

Tests:
```sh
# note this will change when we decide where this package lives
npm install @real_ate/content-tag
```

`cargo test`:
## Usage

Build wasm package:
```js
let { Preprocessor } = require('content-tag');
let p = new Preprocessor();
let output = p.process('<template>Hi</template>');
console.log(output);
```

`wasm-pack build --target=nodejs --scope=ef4`
## Contributing

See wasm package in action:
See the [CONTRIBUTING.md](./CONTRIBUTING.md) file.

```sh
let { Preprocessor } = require('./pkg');
let p = new Preprocessor();
p.process('<template>Hi</template>');
```