Skip to content

Commit 042adb8

Browse files
authored
Merge pull request #30 from CloudCannon/feat/visual-editor-rename
Rename to visual editor api
2 parents d7e35dd + d7561ac commit 042adb8

13 files changed

Lines changed: 133 additions & 290 deletions

File tree

.backstage/get_npm_tag.cjs

Lines changed: 0 additions & 22 deletions
This file was deleted.

.backstage/get_tagged_version.cjs

Lines changed: 0 additions & 18 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 46 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -6,130 +6,60 @@ on:
66
- v*
77

88
jobs:
9-
test-and-build:
10-
runs-on: ubuntu-24.04
9+
test:
10+
uses: ./.github/workflows/test.yml
11+
12+
publish-npm-package:
13+
runs-on: ubuntu-latest
14+
needs: test
15+
outputs:
16+
npm_tag: ${{ steps.npm_tag.outputs.value }}
17+
permissions:
18+
id-token: write
19+
contents: read
20+
packages: write
1121
steps:
12-
- name: Clone
13-
uses: actions/checkout@v3
14-
15-
- uses: actions/setup-node@v4
22+
- uses: actions/checkout@v6
23+
- name: Get tag
24+
id: npm_tag
25+
run: |
26+
VERSION="${GITHUB_REF_NAME#v}"
27+
# e.g.: x.y.z -> latest, x.y.z-rc.1 -> rc
28+
TAG=$([[ "$VERSION" == *-* ]] && echo "${VERSION#*-}" | cut -d. -f1 || echo latest)
29+
echo "value=$TAG" >> $GITHUB_OUTPUT
30+
- uses: actions/setup-node@v6
1631
with:
17-
cache: "npm"
18-
node-version-file: '.nvmrc'
19-
32+
cache: npm
33+
node-version-file: .nvmrc
34+
registry-url: https://registry.npmjs.org
35+
- name: Set version in package.json
36+
run: npm --no-git-tag-version version "${GITHUB_REF_NAME#v}"
2037
- name: Install
2138
run: npm ci
22-
2339
- name: Build
2440
run: npm run build
25-
26-
- name: Unit Test
27-
run: npm run test
28-
29-
- name: Upload dist
30-
uses: actions/upload-artifact@v4
31-
with:
32-
name: dist
33-
path: |
34-
dist/*
35-
36-
publish-github-release:
37-
name: Publish to GitHub
38-
runs-on: ubuntu-24.04
39-
needs: test-and-build
40-
steps:
41-
- name: Get Token
42-
id: get_workflow_token
43-
uses: peter-murray/workflow-application-token-action@v2
44-
with:
45-
application_id: ${{ secrets.CC_OSS_BOT_ID }}
46-
application_private_key: ${{ secrets.CC_OSS_BOT_PEM }}
47-
48-
- name: Swap to main
49-
uses: actions/checkout@v3
50-
with:
51-
ref: main
52-
fetch-depth: 0 # Full fetch
53-
token: ${{ steps.get_workflow_token.outputs.token }}
54-
55-
- name: Get Version
56-
run: |
57-
GIT_VERSION=$(node ./.backstage/get_tagged_version.cjs)
58-
echo GIT_VERSION="$GIT_VERSION" >> $GITHUB_ENV
59-
- name: Get Release Tag
60-
run: |
61-
NPM_TAG=$(node ./.backstage/get_npm_tag.cjs)
62-
echo NPM_TAG="$NPM_TAG" >> $GITHUB_ENV
63-
64-
- name: Download dist
65-
uses: actions/download-artifact@v4
41+
- name: Publish package on npm
42+
run: npm publish --tag ${{ steps.npm_tag.outputs.value }}
43+
- uses: actions/setup-node@v6
6644
with:
67-
name: dist
68-
path: dist
69-
70-
- name: List files
71-
run: ls -R dist
72-
73-
- name: Stable Release
74-
uses: softprops/action-gh-release@v2.2.2
75-
if: startsWith(github.ref, 'refs/tags/') && env.NPM_TAG == 'latest'
76-
with:
77-
files: |
78-
dist/*
45+
registry-url: https://npm.pkg.github.com
46+
- name: Publish package on GitHub
47+
run: npm publish --tag ${{ steps.npm_tag.outputs.value }}
7948
env:
80-
GITHUB_TOKEN: ${{ steps.get_workflow_token.outputs.token }}
49+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8150

82-
- name: Prerelease
83-
uses: softprops/action-gh-release@v2.2.2
84-
if: startsWith(github.ref, 'refs/tags/') && env.NPM_TAG != 'latest'
85-
with:
86-
prerelease: true
87-
files: |
88-
dist/*
89-
env:
90-
GITHUB_TOKEN: ${{ steps.get_workflow_token.outputs.token }}
91-
92-
publish-npm-release:
93-
runs-on: ubuntu-24.04
94-
needs: publish-github-release
51+
create-github-release:
52+
runs-on: ubuntu-latest
53+
needs: publish-npm-package
54+
permissions:
55+
contents: write
9556
steps:
96-
- name: Clone
97-
uses: actions/checkout@v3
98-
99-
- uses: actions/setup-node@v4
100-
with:
101-
cache: "npm"
102-
node-version-file: '.nvmrc'
103-
104-
- name: Get Version
57+
- name: Create release
10558
run: |
106-
GIT_VERSION=$(node ./.backstage/get_tagged_version.cjs)
107-
echo GIT_VERSION="$GIT_VERSION" >> $GITHUB_ENV
108-
- name: Get Release Tag
109-
run: |
110-
NPM_TAG=$(node ./.backstage/get_npm_tag.cjs)
111-
echo NPM_TAG="$NPM_TAG" >> $GITHUB_ENV
112-
113-
- name: Prepare package
114-
run: |
115-
npm --no-git-tag-version version $GIT_VERSION
116-
117-
- name: Install
118-
run: npm ci
119-
120-
- name: Build
121-
run: npm run build
122-
123-
- name: Publish internal
124-
uses: JS-DevTools/npm-publish@v3
125-
with:
126-
tag: ${{ env.NPM_TAG }}
127-
token: ${{ secrets.GITHUB_TOKEN }}
128-
registry: "https://npm.pkg.github.com"
129-
130-
- name: Publish external
131-
uses: JS-DevTools/npm-publish@v3
132-
with:
133-
tag: ${{ env.NPM_TAG }}
134-
token: ${{ secrets.NPM_TOKEN }}
135-
access: public
59+
if [ "${{ needs.publish-npm-package.outputs.npm_tag }}" = "latest" ]; then
60+
gh release create ${{ github.ref_name }} --generate-notes --repo ${{ github.repository }}
61+
else
62+
gh release create ${{ github.ref_name }} --generate-notes --prerelease --repo ${{ github.repository }}
63+
fi
64+
env:
65+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/test.yml

Lines changed: 14 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -2,67 +2,25 @@ name: Test
22

33
on:
44
push:
5-
branches: ["main"]
5+
branches:
6+
- main
67
pull_request:
7-
branches: [main]
8+
branches:
9+
- main
10+
workflow_call:
811

912
jobs:
1013
test:
11-
name: Test
12-
runs-on: ${{matrix.os}}
13-
defaults:
14-
run:
15-
shell: bash
16-
strategy:
17-
matrix:
18-
include:
19-
- build: linux
20-
os: ubuntu-24.04
14+
runs-on: ubuntu-latest
2115
steps:
22-
- name: Checkout repository
23-
uses: actions/checkout@v3
16+
- uses: actions/checkout@v6
17+
- uses: actions/setup-node@v6
2418
with:
25-
fetch-depth: 1
26-
27-
- uses: actions/setup-node@v4
28-
with:
29-
cache: "npm"
30-
node-version-file: '.nvmrc'
31-
32-
- name: Install
19+
cache: npm
20+
node-version-file: .nvmrc
21+
- name: Install
3322
run: npm ci
34-
35-
- name: Build
23+
- name: Lint
24+
run: npm run lint
25+
- name: Build
3626
run: npm run build
37-
38-
- name: Unit Test
39-
run: npm run test
40-
41-
lint:
42-
name: Lint
43-
runs-on: ${{matrix.os}}
44-
defaults:
45-
run:
46-
shell: bash
47-
strategy:
48-
matrix:
49-
include:
50-
- build: linux
51-
os: ubuntu-24.04
52-
steps:
53-
- name: Checkout repository
54-
uses: actions/checkout@v3
55-
with:
56-
fetch-depth: 1
57-
58-
- uses: actions/setup-node@v4
59-
with:
60-
cache: "npm"
61-
node-version-file: '.nvmrc'
62-
63-
- name: Install
64-
run: |
65-
npm ci
66-
67-
- name: Lint Javascript
68-
run: npm run lint

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# JavaScript API
1+
# Visual Editor API
22

3-
Contains TypeScript declarations for the [CloudCannon](https://cloudcannon.com/) JavaScript API.
3+
Contains TypeScript declarations for the [CloudCannon](https://cloudcannon.com/) Visual Editor API.
44

5-
[<img src="https://img.shields.io/npm/v/@cloudcannon%2Fjavascript-api?logo=npm" alt="version badge">](https://www.npmjs.com/package/@cloudcannon%2Fjavascript-api)
5+
[<img src="https://img.shields.io/npm/v/@cloudcannon%2Fvisual-editor-api?logo=npm" alt="version badge">](https://www.npmjs.com/package/@cloudcannon%2Fvisual-editor-api)
66

77
---
88

@@ -16,7 +16,7 @@ Contains TypeScript declarations for the [CloudCannon](https://cloudcannon.com/)
1616
## Installation
1717

1818
```sh
19-
npm i -D @cloudcannon/javascript-api
19+
npm i -D @cloudcannon/visual-editor-api
2020
```
2121

2222
## Development

biome.json

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,9 @@
11
{
2-
"$schema": "https://biomejs.dev/schemas/2.4.12/schema.json",
2+
"$schema": "https://biomejs.dev/schemas/2.4.14/schema.json",
33
"vcs": { "enabled": true, "clientKind": "git", "useIgnoreFile": true },
44
"files": {
55
"ignoreUnknown": false,
6-
"includes": [
7-
"**",
8-
"!**/.zed",
9-
"!**/.backstage",
10-
"!**/package.json",
11-
"!**/package-lock.json",
12-
"!examples"
13-
]
6+
"includes": ["**", "!**/.zed", "!**/package.json", "!**/package-lock.json", "!examples"]
147
},
158
"formatter": {
169
"enabled": true,

examples/file-browser/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# CloudCannon File Browser
22

3-
A modern file browser and code editor built with React and Monaco Editor that integrates with the CloudCannon JavaScript API v1.
3+
A modern file browser and code editor built with React and Monaco Editor that integrates with the CloudCannon Visual Editor API v1.
44

55
## Features
66

@@ -18,7 +18,7 @@ A modern file browser and code editor built with React and Monaco Editor that in
1818
This application is designed to run within the CloudCannon editor environment. Make sure you have:
1919

2020
- Access to CloudCannon editor
21-
- The CloudCannon JavaScript API available on the window object
21+
- The CloudCannon Visual Editor API available on the window object
2222

2323
### Installation
2424

@@ -59,7 +59,7 @@ The built files will be in the `dist` directory. Create a site on CloudCannon us
5959

6060
### API Integration
6161

62-
The application uses the CloudCannon JavaScript API v1:
62+
The application uses the CloudCannon Visual Editor API v1:
6363

6464
```typescript
6565
// Access the API
@@ -171,4 +171,4 @@ If you encounter build issues:
171171

172172
## License
173173

174-
This project is part of the CloudCannon JavaScript API examples and follows the same license terms.
174+
This project is part of the CloudCannon Visual Editor API examples and follows the same license terms.

examples/file-browser/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"@monaco-editor/react": "^4.6.0",
1616
"monaco-editor": "^0.45.0",
1717
"lucide-react": "^0.294.0",
18-
"@cloudcannon/javascript-api": "file:../../"
18+
"@cloudcannon/visual-editor-api": "file:../../"
1919
},
2020
"devDependencies": {
2121
"@types/react": "^18.2.43",

0 commit comments

Comments
 (0)