Skip to content

Commit 61e02bf

Browse files
davesnxDavid Sancho Moreno
andauthored
Create js/native with copy_files under styled-ppx.css/bs-css (#353)
Co-authored-by: David Sancho Moreno <david.sancho@ahrefs.com>
1 parent 6419465 commit 61e02bf

File tree

109 files changed

+12892
-7122
lines changed

Some content is hidden

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

109 files changed

+12892
-7122
lines changed

.github/workflows/ci.yml

Lines changed: 38 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ jobs:
3030
steps:
3131
- uses: actions/checkout@v3
3232

33+
# https://github.com/mmottl/pcre-ocaml/issues/18
34+
# https://github.com/actions/runner-images/issues/6634
35+
- name: Install pcre (only MacOS)
36+
if: matrix.os == 'macos-latest'
37+
run: brew install pcre
38+
3339
- name: Use Node.js
3440
uses: actions/setup-node@v3
3541

@@ -54,12 +60,12 @@ jobs:
5460
path: _opam
5561
key: opam-${{ matrix.os }}-${{ hashFiles('**.opam') }}
5662

57-
- name: Install pins
58-
run: make pin
59-
6063
- name: Install dependencies
6164
run: make install
6265

66+
- name: Install pins
67+
run: make pin
68+
6369
- name: Build
6470
run: make build
6571

@@ -99,6 +105,20 @@ jobs:
99105
name: ${{ matrix.os }}
100106
path: _build/default/bin/bin.exe
101107

108+
- name: Upload runtime artifacts for @davesnx/styled-ppx/runtime/css
109+
if: matrix.os == 'ubuntu-20.04'
110+
uses: actions/upload-artifact@v3
111+
with:
112+
name: runtime-css
113+
path: _build/default/packages/css/rescript
114+
115+
- name: Upload runtime artifacts for @davesnx/styled-ppx/runtime/emotion
116+
if: matrix.os == 'ubuntu-20.04'
117+
uses: actions/upload-artifact@v3
118+
with:
119+
name: runtime-emotion
120+
path: _build/default/packages/emotion/rescript
121+
102122
- name: Save cache when not Windows
103123
uses: actions/cache/save@v3
104124
if: steps.opam-cache.outputs.cache-hit != 'true' && runner.os != 'Windows'
@@ -113,26 +133,6 @@ jobs:
113133
path: _opam
114134
key: opam-${{ matrix.os }}-${{ hashFiles('**.opam') }}
115135

116-
e2e:
117-
name: Browser tests
118-
runs-on: ${{ matrix.os }}
119-
needs: build
120-
strategy:
121-
matrix:
122-
os: [ubuntu-20.04, macos-latest]
123-
124-
steps:
125-
- uses: actions/checkout@v3
126-
127-
- name: Use Node.js
128-
uses: actions/setup-node@v3
129-
130-
- name: Download artifacts
131-
uses: actions/download-artifact@v3
132-
with:
133-
name: ${{ matrix.os }}
134-
path: _build/default/bin
135-
136136
- name: Grant permission to run ppx
137137
run: chmod +x _build/default/bin/bin.exe
138138

@@ -185,20 +185,33 @@ jobs:
185185
# name: windows-latest
186186
# path: _release/platform-windows-x64
187187

188-
- name: Release nightly NPM package
188+
- name: Download runtime-css artifacts
189+
uses: actions/download-artifact@v3
190+
with:
191+
name: runtime-css
192+
path: _release/css
193+
194+
- name: Download runtime-emotion artifacts
195+
uses: actions/download-artifact@v3
196+
with:
197+
name: runtime-emotion
198+
path: _release/emotion
199+
200+
- name: Release nightly (@davesnx/styled-ppx) package
189201
if: ${{ success() && github.event_name == 'pull_request' && github.event.pull_request.user.login == 'davesnx' }}
190202
id: nightly
191203
working-directory: ./_release
192204
env:
193205
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
194206
run: |
207+
ls -lhsa
195208
npm config set //registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN
196209
npm config set scope "@davesnx"
197210
npm version prerelease --preid ${{ steps.sha.outputs.sha_short }} -no-git-tag-version
198211
npm publish --access public --tag nightly
199212
echo "version=$(npm view @davesnx/styled-ppx@nightly version)" >> $GITHUB_OUTPUT
200213
201-
- name: Release NPM package
214+
- name: Release (@davesnx/styled-ppx) package
202215
if: ${{ success() && github.event_name != 'pull_request' }}
203216
working-directory: ./_release
204217
env:

.ocamlformat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version=0.24.1
1+
version=0.26.0
22
quiet=true
33
profile=default
44
ocaml-version=4.14.0

Makefile

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,24 +35,23 @@ format-check: ## Checks if format is correct
3535
fmt format: ## Formats code
3636
$(DUNE) build @fmt --auto-promote
3737

38-
.PHONY: init
38+
.PHONY: setup-githooks
3939
setup-githooks: ## Setup githooks
4040
@git config core.hooksPath .githooks
4141

4242
.PHONY: pin
4343
pin: ## Pin dependencies
44-
# @opam pin add dune.dev "https://github.com/ocaml/dune.git#7fdf0ca379f773deb21f97c7a66c1b9b0bbd4f98" -y
44+
@opam pin add melange.dev "https://github.com/melange-re/melange.git#d4868a5300c8c6e9f1b387aedb85ded4a705bc0a" -y
4545
@opam pin add reason.dev "https://github.com/reasonml/reason.git#b283f335f90e3aaa398bff8e82761038ee42a99d" -y
4646
@opam pin add ppxlib.dev "https://github.com/ocaml-ppx/ppxlib.git#8b8987c5690ad839348d96bf52471b03b88f06ed" -y
47-
# @opam pin add melange.dev "https://github.com/melange-re/melange.git#da421be55e755096403425ed3c260486deab61f3" -y
48-
# @opam pin add rescript-syntax.dev "https://github.com/melange-re/melange.git#2ee0ef23bbc44933f92cd9c4b223e9ef915ff0df" -y
47+
@opam pin add server-reason-react.dev "https://github.com/ml-in-barcelona/server-reason-react.git#f46fa4bd9a5490bd3a6d64e1e77dab66028a6a2f" -y
4948

5049
.PHONY: create-switch
5150
create-switch: ## Create opam switch
52-
@opam switch create . 4.14.0 --deps-only --with-test
51+
@opam switch create . 4.14.1 --deps-only --with-test --no-install
5352

5453
.PHONY: install
55-
install: ## Update the package dependencies when new deps are added to dune-project
54+
install: ## Install project dependencies
5655
@opam install . --deps-only --with-test
5756
@yarn install
5857

@@ -121,8 +120,12 @@ test_e2e: ## Run End-to-end tests for JSX3
121120
test_string_interpolation: ## Run string_interpolation tests
122121
$(DUNE) build @string_interpolation_test
123122

123+
.PHONY: test_emotion
124+
test_emotion: ## Run emotion tests
125+
$(DUNE) build @emotion_test
126+
124127
.PHONY: test_all
125-
test_all: build test_typecheck test_css_support test_ppx_snapshot test_parser test_css_lexer test_reason_css_parser test_css_spec_parser test_css_spec_types test_string_interpolation test_e2e
128+
test_all: build test_typecheck test_css_support test_ppx_snapshot test_parser test_css_lexer test_reason_css_parser test_css_spec_parser test_css_spec_types test_string_interpolation test_emotion test_e2e
126129

127130
# Debug commands
128131

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ Add `"@davesnx/styled-ppx/ppx"` under bsconfig `"ppx-flags"`:
2020
{
2121
"bs-dependencies": [
2222
"@rescript/react",
23-
"bs-css",
24-
"bs-css-emotion"
23+
+ "@davesnx/styled-ppx/css",
24+
+ "@davesnx/styled-ppx/emotion"
2525
],
2626
+ "ppx-flags": ["@davesnx/styled-ppx/ppx"]
2727
}

bin/dune

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
(executable
22
(name bin)
33
(public_name styled-ppx)
4-
(libraries styled-ppx.lib))
4+
(libraries styled-ppx.lib ppxlib))

dune

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
1-
(dirs bin packages)
1+
(dirs bin packages e2e)
2+
3+
(subdir
4+
e2e
5+
(dirs melange-v1))
26

37
(subdir
48
packages
59
(dirs
6-
bs-css
7-
bs-css-emotion
810
css
11+
emotion
12+
emotion-hash
913
css-spec-parser
1014
parser
1115
ppx

dune-project

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
(generate_opam_files true)
1010

11+
(implicit_transitive_deps false)
12+
1113
(source (github davesnx/styled-ppx))
1214
(homepage "https://styled-ppx.vercel.app")
1315
(documentation "https://styled-ppx.vercel.app")
@@ -25,8 +27,8 @@
2527
(description
2628
"styled-ppx is the ppx that brings styled components to ReScript and Melange, allowing you to create React Components with type-safe style definitions using CSS.")
2729
(depends
28-
(ocaml (>= 4.14.1))
29-
(menhir (= 20220210))
30+
(ocaml (and (>= 4.14.0) (< 5.0.0)))
31+
(menhir (>= 20220210))
3032
(ppx_deriving (>= 5.0))
3133
(ppx_deriving_yojson (>= 3.7.0))
3234
(ppxlib (>= 0.27.0))

e2e/melange-v1/dune

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
(melange.emit
2+
(alias e2e-melange)
3+
(target e2e-melange)
4+
(libraries ui)
5+
(module_systems
6+
(commonjs bs.js)))

e2e/melange-v1/index.re

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
let _ = Ui.stackGap(`px(10));
2+
3+
Js.log(Ui.selectors);

0 commit comments

Comments
 (0)