Skip to content

Commit a4da3d0

Browse files
committed
twind.run updates
1 parent 3ba2681 commit a4da3d0

44 files changed

Lines changed: 1526 additions & 670 deletions

Some content is hidden

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

.changeset/config.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,5 @@
77
"access": "public",
88
"baseBranch": "next",
99
"updateInternalDependencies": "patch",
10-
"ignore": [],
11-
"snapshot": {
12-
"useCalculatedVersion": true
13-
}
10+
"ignore": []
1411
}

.github/actions/publish-pages.yml

Lines changed: 36 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ inputs:
3131
branch:
3232
description: 'The name of the branch you want to deploy to'
3333
required: false
34-
default: 'preview'
34+
default: ${{ (github.event.number && format('pr-{0}', github.event.number)) || (github.event_name == 'pull_request' && 'canary') || 'next' }}
3535

3636
outputs:
3737
id:
@@ -43,20 +43,32 @@ outputs:
4343
environment:
4444
description: 'The environment that was deployed to'
4545
value: ${{ steps.deploy.outputs.environment }}
46-
alias:
47-
description: 'The alias of the pages deployment'
46+
branch:
47+
description: 'The branch alias of the pages deployment'
4848
value: ${{ steps.deploy.outputs.alias }}
49+
version:
50+
description: 'The version alias of the pages deployment'
51+
value: ${{ steps.version.outputs.alias }}
52+
branchURL:
53+
description: 'The branch url of the pages deployment'
54+
value: https://${{ steps.deploy.outputs.alias }}${{ inputs.projectName }}.pages.dev
55+
versionURL:
56+
description: 'The version url of the pages deployment'
57+
value: https://${{ steps.alias.outputs.alias }}${{ inputs.projectName }}.pages.dev
4958

5059
runs:
5160
using: 'composite'
5261
steps:
5362
# deploy twind.run using the published package versions
54-
- name: 🏗️ Build
63+
- name: 🏗️ Build ${{ inputs.workingDirectory }}
64+
id: build
5565
shell: bash
56-
run: ${{ inputs.run }}
66+
run: |
67+
${{ inputs.run }}
68+
echo version="`jq '.version' package.json`" >> $GITHUB_OUTPUT
5769
working-directory: ${{ inputs.workingDirectory }}
5870

59-
- name: 🚀 Deploy
71+
- name: 🚀 Deploy ${{ inputs.workingDirectory }} as ${{ inputs.branch }}
6072
id: deploy
6173
# until https://github.com/cloudflare/pages-action/pull/33 is merged
6274
uses: cloudflare/pages-action@walshy/general-improvements
@@ -65,28 +77,30 @@ runs:
6577
accountId: ${{ inputs.accountId }}
6678
gitHubToken: ${{ inputs.gitHubToken }}
6779
projectName: ${{ inputs.projectName }}
68-
directory: ${{ inputs.directory }}
80+
directory: ${{ inputs.workingDirectory }}/${{ inputs.directory }}
6981
branch: ${{ inputs.branch }}
7082

83+
- name: 🚀 Deploy ${{ inputs.workingDirectory }} as v${{ steps.build.outputs.version }}
84+
id: version
85+
# until https://github.com/cloudflare/pages-action/pull/33 is merged
86+
uses: cloudflare/pages-action@walshy/general-improvements
87+
continue-on-error: true
88+
with:
89+
apiToken: ${{ inputs.apiToken }}
90+
accountId: ${{ inputs.accountId }}
91+
gitHubToken: ${{ inputs.gitHubToken }}
92+
projectName: ${{ inputs.projectName }}
93+
directory: ${{ inputs.workingDirectory }}/${{ inputs.directory }}
94+
# Branch name aliases are lowercased and non-alphanumeric characters are replaced with a hyphen
95+
# v1.0.0.next.39 -> v1-0-0-next-39
96+
branch: v${{ steps.build.outputs.version }}
97+
7198
- name: 💡 Deployment Info
7299
shell: bash
73100
run: |
74101
echo "## Deployed with [![Cloudflare](https://img.shields.io/badge/Cloudflare%20Pages-F38020?style=for-the-badge&logo=Cloudflare&logoColor=white)](https://pages.dev)" >> $GITHUB_STEP_SUMMARY
75102
echo "<strong>ID:</strong> ${{ steps.deploy.outputs.id }}" >> $GITHUB_STEP_SUMMARY
76-
echo "<strong>Preview URL:</strong> <a href='${{ steps.deploy.outputs.url }}'>${{ steps.deploy.outputs.url }}</a>" >> $GITHUB_STEP_SUMMARY
103+
echo "<strong>Deployment URL:</strong> <a href='${{ steps.deploy.outputs.url }}'>${{ steps.deploy.outputs.url }}</a>" >> $GITHUB_STEP_SUMMARY
77104
echo "<strong>Branch URL:</strong> <a href='https://${{ steps.deploy.outputs.alias }}${{ inputs.projectName }}.pages.dev'>https://${{ steps.deploy.outputs.alias }}${{ inputs.projectName }}.pages.dev</a>" >> $GITHUB_STEP_SUMMARY
105+
echo "<strong>Version URL:</strong> <a href='https://${{ steps.alias.outputs.alias }}${{ inputs.projectName }}.pages.dev'>https://${{ steps.alias.outputs.alias }}${{ inputs.projectName }}.pages.dev</a>" >> $GITHUB_STEP_SUMMARY
78106
echo "<strong>Environment:</strong> ${{ steps.deploy.outputs.environment }}" >> $GITHUB_STEP_SUMMARY
79-
80-
- name: 📝 Comment PR
81-
if: ${{ github.event_name == 'pull_request' }}
82-
uses: thollander/actions-comment-pull-request@v1
83-
with:
84-
GITHUB_TOKEN: ${{ inputs.gitHubToken }}
85-
comment_includes: '## Deployed with [![Cloudflare Pages]'
86-
message: |
87-
## Deployed with [![Cloudflare Pages](https://img.shields.io/badge/Cloudflare%20Pages-F38020?style=for-the-badge&logo=Cloudflare&logoColor=white)](https://pages.dev)
88-
<table>
89-
<tr><td><strong>Latest commit:</strong></td><td><code>${{ github.sha }}</code></td></tr>
90-
<tr><td><strong>Preview URL:</strong></td><td><a href='${{ steps.deploy.outputs.url }}'>${{ steps.deploy.outputs.url }}</a></td></tr>
91-
<tr><td><strong>Branch URL:</strong></td><td><a href='https://${{ steps.deploy.outputs.alias }}${{ inputs.projectName }}.pages.dev'>https://${{ steps.deploy.outputs.alias }}${{ inputs.projectName }}.pages.dev</a></td></tr>
92-
</table>

.github/actions/publish-prerelease.yml

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ inputs:
2020
description: 'GitHub Token'
2121
required: false
2222

23+
outputs:
24+
tag:
25+
description: 'the npm dist-tag'
26+
value: ${{inputs.tag }}
27+
packages:
28+
description: 'markdown list of published packages and version'
29+
value: ${{ steps.publish.output.packages }}
30+
2331
runs:
2432
using: 'composite'
2533
steps:
@@ -55,25 +63,12 @@ runs:
5563
shell: bash
5664
run: |
5765
pnpm release --tag ${{ inputs.tag }} --no-git-checks --report-summary
58-
echo packages="`jq '[.publishedPackages[] | join("@")] | join("\n - ")' pnpm-publish-summary.json`" >> $GITHUB_OUTPUT
66+
echo packages="`jq '.publishedPackages | map("- [" +.name+"@"+.version+"](https://www.npmjs.com/package/"+.name+"/v/"+.version+")") | join("\n")' pnpm-publish-summary.json`" >> $GITHUB_OUTPUT
5967
60-
- name: 💡 Deployment Info
68+
- name: 💡 Publish Info
6169
shell: bash
6270
run: |
6371
echo "## Published packages to npm (dist-tag: ${{ inputs.tag }})" >> $GITHUB_STEP_SUMMARY
64-
jq '[.publishedPackages[] | join("@")] | join(", ")' pnpm-publish-summary.json >> $GITHUB_STEP_SUMMARY
65-
66-
- name: 📝 Comment PR
67-
if: ${{ inputs.gitHubToken && github.event_name == 'pull_request' }}
68-
uses: thollander/actions-comment-pull-request@v1
69-
with:
70-
GITHUB_TOKEN: ${{ inputs.gitHubToken }}
71-
comment_includes: '## Published pre-releases to npm'
72-
message: |
73-
## Published pre-releases to npm
74-
75-
**Dist Tag**: ${{ inputs.tag }}
76-
77-
**Packages**:
78-
79-
- ${{ stepps.publish.output.packages }}
72+
echo "**Dist Tag**: ${{ inputs.tag }}" >> $GITHUB_STEP_SUMMARY
73+
echo "**Packages**:" >> $GITHUB_STEP_SUMMARY
74+
echo "${{ steps.publish.output.packages }}" >> $GITHUB_STEP_SUMMARY

.github/actions/setup.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ runs:
2424
steps:
2525
- name: 📥 Checkout
2626
uses: actions/checkout@v3
27+
with:
28+
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
29+
fetch-depth: 0
2730

2831
- name: 🔧 Setup Node.js
2932
uses: actions/setup-node@v3

.github/workflows/ci.yml

Lines changed: 49 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ concurrency:
1313
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
1414
cancel-in-progress: true
1515

16-
env:
17-
CI: true
18-
1916
jobs:
2017
build:
2118
name: 🏗️ Build on Node.js v${{ matrix.node }}
@@ -24,6 +21,9 @@ jobs:
2421
outputs:
2522
published: ${{ steps.changesets.outputs.published }}
2623
hasChangesets: ${{ steps.changesets.outputs.hasChangesets }}
24+
permissions:
25+
contents: write # to create release (changesets/action)
26+
pull-requests: write # to create pull request (changesets/action)
2727

2828
strategy:
2929
matrix:
@@ -92,7 +92,7 @@ jobs:
9292
accountId: ${{ secrets.CF_ACCOUNT_ID }}
9393
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
9494
projectName: twind-style
95-
directory: sites/twind.style/build
95+
directory: build
9696
branch: main
9797

9898
- name: 🌎 Deploy twind.run
@@ -104,7 +104,7 @@ jobs:
104104
accountId: ${{ secrets.CF_ACCOUNT_ID }}
105105
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
106106
projectName: twind-run
107-
directory: sites/twind.run/.svelte-kit/cloudflare
107+
directory: .svelte-kit/cloudflare
108108
branch: main
109109

110110
coveralls:
@@ -128,7 +128,7 @@ jobs:
128128
if: ${{ needs.build.outputs.published != 'true' && github.repository == 'tw-in-js/twind' }}
129129
permissions:
130130
contents: read
131-
pull-requests: read
131+
pull-requests: write
132132
deployments: write
133133

134134
steps:
@@ -138,26 +138,18 @@ jobs:
138138
# only install dependencies for packages that are published and for the sites
139139
installArgs: --filter="./packages/*" --filter="@sites/*"
140140

141-
- name: 🚚 Publish as pre-release (@next.<DATETIME>)
142-
if: ${{ github.event_name == 'push' }}
141+
- name: 🚚 Publish pre-release to npm
142+
id: publish
143143
uses: ./.github/actions/publish-prerelease
144144
with:
145-
tag: next
146-
template: '{tag}.{datetime}'
147-
hasChangesets: ${{ needs.build.outputs.hasChangesets }}
148-
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
149-
150-
- name: 🚚 Publish as canary release (@canary-<commit>)
151-
if: ${{ github.event_name == 'pull_request' }}
152-
uses: ./.github/actions/publish-prerelease
153-
with:
154-
tag: canary
155-
template: '{tag}-{commit}'
145+
tag: ${{ (github.event_name == 'push' && 'next') || 'canary'}}
146+
template: ${{ (github.event_name == 'push' && '{tag}-{datetime}') || '{tag}-{commit}'}}
156147
hasChangesets: ${{ needs.build.outputs.hasChangesets }}
157148
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
158149

159150
# deploy sites using the published package versions
160151
- name: 🌎 Deploy twind.style
152+
id: deploy_twind_style
161153
uses: ./.github/actions/publish-pages
162154
with:
163155
workingDirectory: sites/twind.style
@@ -168,16 +160,50 @@ jobs:
168160
accountId: ${{ secrets.CF_ACCOUNT_ID }}
169161
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
170162
projectName: twind-style
171-
directory: sites/twind.style/build
172-
branch: ${{ (github.event.number && format('pr-{0}', github.event.number)) || (github.event_name == 'pull_request' && 'canary') || 'next' }}
163+
directory: build
173164

174165
- name: 🌎 Deploy twind.run
166+
id: deploy_twind_run
175167
uses: ./.github/actions/publish-pages
176168
with:
177169
workingDirectory: sites/twind.run
178170
apiToken: ${{ secrets.CF_API_TOKEN }}
179171
accountId: ${{ secrets.CF_ACCOUNT_ID }}
180172
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
181173
projectName: twind-run
182-
directory: sites/twind.run/.svelte-kit/cloudflare
183-
branch: ${{ (github.event.number && format('pr-{0}', github.event.number)) || (github.event_name == 'pull_request' && 'canary') || 'next' }}
174+
directory: .svelte-kit/cloudflare
175+
176+
- name: 📝 Comment PR
177+
if: ${{ github.event_name == 'pull_request' }}
178+
uses: thollander/actions-comment-pull-request@v1
179+
with:
180+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
181+
comment_includes: '## Deployed site previews with [![Cloudflare Pages]'
182+
message: |
183+
> **Latest commit**: ${{ github.sha }}
184+
185+
## Deployed site previews with [![Cloudflare Pages](https://img.shields.io/badge/Cloudflare%20Pages-F38020?style=for-the-badge&logo=Cloudflare&logoColor=white)](https://pages.dev)
186+
187+
### twind.style
188+
189+
<table>
190+
<tr><td><strong>Deployment URL:</strong></td><td><a href='${{ steps.deploy_twind_style.outputs.url }}'>${{ steps.deploy_twind_style.outputs.url }}</a></td></tr>
191+
<tr><td><strong>Branch URL:</strong></td><td><a href='${{ steps.deploy_twind_style.outputs.branchURL }}'>${{ steps.deploy_twind_style.outputs.branchURL }}</a></td></tr>
192+
<tr><td><strong>Version URL:</strong></td><td><a href='${{ steps.deploy_twind_style.outputs.versionURL }}'>${{ steps.deploy_twind_style.outputs.versionURL }}</a></td></tr>
193+
</table>
194+
195+
### twind.run
196+
197+
<table>
198+
<tr><td><strong>Deployment URL:</strong></td><td><a href='${{ steps.deploy_twind_run.outputs.url }}'>${{ steps.deploy_twind_run.outputs.url }}</a></td></tr>
199+
<tr><td><strong>Branch URL:</strong></td><td><a href='${{ steps.deploy_twind_run.outputs.branchURL }}'>${{ steps.deploy_twind_run.outputs.branchURL }}</a></td></tr>
200+
<tr><td><strong>Version URL:</strong></td><td><a href='${{ steps.deploy_twind_run.outputs.versionURL }}'>${{ steps.deploy_twind_run.outputs.versionURL }}</a></td></tr>
201+
</table>
202+
203+
## Published to [npm](https://www.npmjs.com)
204+
205+
**Dist Tag**: ${{ steps.publish.output.tag }}
206+
207+
**Packages**:
208+
209+
${{ steps.publish.output.packages }}

ROADMAP.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,19 @@
3232

3333
- [x] dist tags
3434

35+
- https://support.google.com/chrome/a/answer/9027636?hl=en
3536
- latest: latest stable release - published by changesets/action
36-
- next: latest pre-release - published on every commit to main
37-
- canary: the latest dev release (https://docusaurus.io/community/canary) - published on every commit (main or PR)
37+
- next: upcoming release - published on every commit to main
38+
- canary: the latest dev release (https://docusaurus.io/community/canary) - published for PR commits
39+
40+
- [x] sites
41+
42+
- main: `twind-run.pages.dev` (`twind.run`) latest stable release - published on release
43+
- next: `next.twind-run.pages.dev` upcoming release - published on every commit to main
44+
- canary: `pr-*.twind-run.pages.dev` - published for PR commits
45+
- version: `v1-0-0-next-39.twind-run.pages.dev` - specific version
46+
47+
Branch name aliases are lowercased and non-alphanumeric characters are replaced with a hyphen — for example, the `fix/api` branch creates the `fix-api.<project>.pages.dev` alias.
3848

3949
- @twind/devtools:
4050
- enumerate all classes and inject as empty for dev tools

examples/with-sveltekit/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
"preview": "vite preview"
2424
},
2525
"devDependencies": {
26-
"@sveltejs/adapter-node": "^1.0.0-next.96",
27-
"@sveltejs/kit": "^1.0.0-next.511",
26+
"@sveltejs/adapter-node": "^1.0.0-next.100",
27+
"@sveltejs/kit": "^1.0.0-next.531",
2828
"@twind/preset-autoprefix": "1.0.0-next.39",
2929
"@twind/preset-tailwind": "1.0.0-next.39",
3030
"@twind/with-sveltekit": "1.0.0-next.39",

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,9 @@
9090
"patchedDependencies": {
9191
"@size-limit/esbuild@8.1.0": "patches/@size-limit__esbuild@8.1.0.patch",
9292
"monaco-editor@0.34.1": "patches/monaco-editor@0.34.1.patch",
93-
"@jspm/generator@1.0.0-beta.38": "patches/@jspm__generator@1.0.0-beta.38.patch"
93+
"@jspm/generator@1.0.0-beta.38": "patches/@jspm__generator@1.0.0-beta.38.patch",
94+
"@jsenv/logger@4.1.1": "patches/@jsenv__logger@4.1.1.patch",
95+
"@jsenv/importmap@1.2.1": "patches/@jsenv__importmap@1.2.1.patch"
9496
},
9597
"updateConfig": {
9698
"ignoreDependencies": [

packages/intellisense/src/languages/html.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ import type { ParsedDevRule } from 'twind'
22
import type { ColorInformation, Diagnostics, DocumentationAt } from '../types'
33
import type { IntellisenseContext, Boundary } from '../internal/types'
44

5-
import * as csstree from 'css-tree'
5+
import csstreeParse from 'css-tree/parser'
6+
import csstreeWalk from 'css-tree/walker'
7+
import csstreeGenerate from 'css-tree/generator'
68

79
import { parse } from 'twind'
810
import { fixClassList, parseHTML } from '../../../twind/src/internal/parse-html'
@@ -125,7 +127,7 @@ export function validate(
125127

126128
const css = generateCSS(rule.n)
127129

128-
const ast = csstree.parse(css, {
130+
const ast = csstreeParse(css, {
129131
positions: false,
130132
parseAtrulePrelude: false,
131133
parseRulePrelude: false,
@@ -161,10 +163,10 @@ export function validate(
161163
// }
162164

163165
if (typeof document == 'object') {
164-
csstree.walk(ast, {
166+
csstreeWalk(ast, {
165167
visit: 'SelectorList',
166168
enter(node) {
167-
const selector = csstree.generate(node)
169+
const selector = csstreeGenerate(node)
168170
try {
169171
document.querySelector(selector)
170172
} catch (error) {
@@ -215,7 +217,7 @@ export function validate(
215217

216218
const css = generateCSS(className)
217219

218-
const ast = csstree.parse(css, {
220+
const ast = csstreeParse(css, {
219221
positions: false,
220222
parseAtrulePrelude: false,
221223
parseRulePrelude: false,
@@ -236,10 +238,10 @@ export function validate(
236238

237239
if (ast) {
238240
if (typeof document == 'object') {
239-
csstree.walk(ast, {
241+
csstreeWalk(ast, {
240242
visit: 'SelectorList',
241243
enter(node) {
242-
const selector = csstree.generate(node)
244+
const selector = csstreeGenerate(node)
243245
try {
244246
document.querySelector(selector)
245247
} catch {

0 commit comments

Comments
 (0)