Skip to content

Commit e1c2d15

Browse files
committed
Build and publish v4 lib/ and themes/ folders for backwards compatibility while users transition to v5.
- add a script to build the legacy v4 lib/ and themes/ folders - append deprecation console warnings to the v4 JS files during the v4 build - add a script to clean v4 build outputs - hook the v4 build/clean scripts into the release.sh script - test the v4 build and clean in CI
1 parent 37a2559 commit e1c2d15

File tree

5 files changed

+56
-8
lines changed

5 files changed

+56
-8
lines changed

.github/workflows/test.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,25 @@ jobs:
7272
run: npx playwright install --with-deps
7373
- name: E2E Tests (Playwright)
7474
run: npm run test:e2e
75+
76+
# In the interest of not having to modify GitHub settings to update required
77+
# builds for passing, I stuck this test here.
78+
- name: Test v4 build
79+
run: |
80+
git fetch --tags
81+
npm run build:v4
82+
# ensure v4 build files exist:
83+
test -f lib/docsify.js
84+
test -f themes/pure.css
85+
# ensure no git changes after building v4:
86+
git diff --exit-code
87+
npm run clean:v4
88+
# ensure v4 build files are removed:
89+
test ! -f lib/docsify.js
90+
test ! -f themes/pure.css
91+
# ensure no git changes after cleaning v4:
92+
git diff --exit-code
93+
7594
- name: Store artifacts
7695
uses: actions/upload-artifact@v6
7796
if: failure()

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ node_modules
1414
!.gitkeep
1515

1616
# Output folder for the global build only
17-
dist
17+
dist/
18+
19+
# Output folders for the legacy v4 build
20+
lib/
21+
themes/
1822

1923
# TypeScript declaration files for standard ESM consumption
2024
src/**/*.d.ts

build/release.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ if [[ $REPLY =~ ^[Yy]$ ]]; then
2727
npm run build
2828
npm run test:update:snapshot
2929
npm run test
30+
npm run build:v4 # builds legacy v4 lib/ and themes/ folders for backwards compat while people transition to v5.
3031

3132
# Changelog
3233
npx conventional-changelog -p angular -i CHANGELOG.md -s
@@ -46,4 +47,6 @@ if [[ $REPLY =~ ^[Yy]$ ]]; then
4647
else
4748
npm publish --tag "$RELEASE_TAG"
4849
fi
50+
51+
npm run clean:v4 # clean up legacy v4 build files
4952
fi

docs/quickstart.md

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ After the `init` is complete, you can see the file list in the `./docs` subdirec
2222
- `README.md` as the home page
2323
- `.nojekyll` prevents GitHub Pages from ignoring files that begin with an underscore
2424

25-
You can easily update the documentation in `./docs/README.md`, of course you can add [more pages](adding-pages.md).
25+
You can easily update the documentation in `./docs/README.md`, and of course you can add [more pages](adding-pages.md).
2626

2727
## Preview your site
2828

@@ -76,9 +76,14 @@ Download or create an `index.html` template using the following markup:
7676

7777
### Specifying docsify versions
7878

79-
> [!TIP] Note that in both of the examples below, docsify URLs will need to be manually updated when a new major version of docsify is released (e.g. `v5.x.x` => `v6.x.x`). Check the docsify website periodically to see if a new major version has been released.
79+
> [!TIP] Note that in both of the examples below, docsify URLs will need to be
80+
> manually updated when a new major version of docsify is released (e.g. `v5.x.x`
81+
> => `v6.x.x`). Check the docsify website periodically to see if a new major
82+
> version has been released.
8083
81-
Specifying a major version in the URL (`@5`) will allow your site to receive non-breaking enhancements (i.e. "minor" updates) and bug fixes (i.e. "patch" updates) automatically. This is the recommended way to load docsify resources.
84+
Specifying a major version in the URL (`@5`) will allow your site to receive
85+
non-breaking enhancements (i.e. "minor" updates) and bug fixes (i.e. "patch"
86+
updates) automatically. This is the recommended way to load docsify resources.
8287

8388
<!-- prettier-ignore -->
8489
```html
@@ -89,7 +94,11 @@ Specifying a major version in the URL (`@5`) will allow your site to receive non
8994
<script src="//cdn.jsdelivr.net/npm/docsify@5"></script>
9095
```
9196

92-
If you prefer to lock docsify to a specific version, specify the full version after the `@` symbol in the URL. This is the safest way to ensure your site will look and behave the same way regardless of any changes made to future versions of docsify.
97+
If you'd like to ensure absolutely no possibility of changes that will break
98+
your site (non-major updates can unintentionally introduce breaking changes
99+
despite that they aim not to), specify the full version after the `@` symbol in
100+
the URL. This is the safest way to ensure your site will look and behave the
101+
same way regardless of any changes made to future versions of docsify.
93102

94103
<!-- prettier-ignore -->
95104
```html
@@ -100,9 +109,17 @@ If you prefer to lock docsify to a specific version, specify the full version af
100109
<script src="//cdn.jsdelivr.net/npm/docsify@5.0.0"></script>
101110
```
102111

112+
JSDelivr supports [npm-compatible semver ranges](https://docs.npmjs.com/cli/v11/configuring-npm/package-json#dependencies),
113+
so you can also use version syntax such as `@^5.0.0` for the latest v5 release,
114+
`@5.0.x` for the latest v5.0 patch release (f.e. you will receive 5.0.4 but
115+
not 5.1.0), `@5.x` for the latest v5 minor and patch releases (which is
116+
effectively the same as `@5` and `@^5.0.0`), etc.
117+
103118
### Manually preview your site
104119

105-
If you have Python installed on your system, you can easily use it to run a static server to preview your site.
120+
If you have Python installed on your system, you can easily use it to run a
121+
static server to preview your site instead of using `docsify serve` from
122+
`docsify-cli`.
106123

107124
```python
108125
# Python 2

package.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@
3131
},
3232
"files": [
3333
"dist",
34-
"src"
34+
"src",
35+
"lib",
36+
"themes"
3537
],
3638
"lint-staged": {
3739
"*.js": "eslint --fix"
@@ -93,8 +95,11 @@
9395
"build:emoji": "node ./build/emoji.js",
9496
"build:js": "rollup -c",
9597
"build:types": "tsc",
98+
"build:v4": "git checkout v4 && npm clean-install && git co docs/emoji.md src/core/render/emoji-data.js && rimraf packages/ && git checkout - && npm clean-install && npm run build:v4:deprecate -- lib/docsify.js && npm run build:v4:deprecate -- lib/docsify.min.js",
99+
"build:v4:deprecate": "echo ';console.warn(\"Docsify v4 is no longer supported. See https://docsify.js.org for the latest version.\")' >> ",
96100
"build": "run-s clean build:types build:js build:css build:css:min build:cover",
97-
"clean": "rimraf --glob \"dist/**\" \"themes/**\" \"_playwright*/**\" \"src/**/*.d.ts\" \"src/**/*.d.ts.map\"",
101+
"clean": "rimraf --glob \"dist/**\" \"_playwright*/**\" \"src/**/*.d.ts\" \"src/**/*.d.ts.map\"",
102+
"clean:v4": "rimraf lib/ themes/",
98103
"dev": "run-p serve:dev watch:*",
99104
"docker:build:test": "npm run docker:cli -- build:test",
100105
"docker:build": "docker build -f Dockerfile -t docsify-test:local .",

0 commit comments

Comments
 (0)