Skip to content

Commit e9f9747

Browse files
authored
feat: convert project to monorepo, setup changesets (#127)
1 parent 3e1225d commit e9f9747

Some content is hidden

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

73 files changed

+1909
-338
lines changed

.changeset/config.json

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
3+
"changelog": "@changesets/cli/changelog",
4+
"commit": false,
5+
"linked": [],
6+
"access": "public",
7+
"baseBranch": "master",
8+
"updateInternalDependencies": "patch",
9+
"ignore": ["@api-viewer-fixtures/lit"]
10+
}

.changeset/pre.json

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"mode": "pre",
3+
"tag": "pre",
4+
"initialVersions": {
5+
"@api-viewer/common": "1.0.0-pre.0",
6+
"@api-viewer/demo": "1.0.0-pre.0",
7+
"@api-viewer/docs": "1.0.0-pre.0",
8+
"@api-viewer/tabs": "1.0.0-pre.0",
9+
"api-viewer-element": "1.0.0-pre.0",
10+
"@api-viewer-fixtures/lit": "0.0.0"
11+
},
12+
"changesets": []
13+
}

.changeset/rich-berries-prove.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
'@api-viewer/common': patch
3+
'@api-viewer/demo': patch
4+
'@api-viewer/docs': patch
5+
'@api-viewer/tabs': patch
6+
'api-viewer-element': patch
7+
---
8+
9+
Convert api-viewer-element to monorepo

.eslintrc.json

+8
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@
4141
"rules": {
4242
"@typescript-eslint/no-explicit-any": "off"
4343
}
44+
},
45+
{
46+
"files": ["scripts/*.js"],
47+
"rules": {
48+
"import/no-extraneous-dependencies": "off",
49+
"no-console": "off",
50+
"no-restricted-syntax": "off"
51+
}
4452
}
4553
]
4654
}

.github/workflows/release.yml

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
release:
10+
# Prevents changesets action from creating a PR on forks
11+
if: github.repository == 'open-wc/api-viewer-element'
12+
name: Release
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout Repo
16+
uses: actions/checkout@v2
17+
with:
18+
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
19+
fetch-depth: 0
20+
21+
- name: Setup Node.js
22+
uses: actions/setup-node@v2
23+
with:
24+
node-version: '16'
25+
cache: 'yarn'
26+
27+
- name: Install Dependencies
28+
run: yarn --frozen-lockfile
29+
30+
- name: Build packages
31+
run: yarn build
32+
33+
- name: Analyze
34+
run: yarn analyze
35+
36+
- name: Create Release Pull Request or Publish to npm
37+
id: changesets
38+
uses: changesets/action@v1
39+
with:
40+
# This expects you to have a script called release which does a build for your packages and calls changeset publish
41+
publish: yarn release
42+
env:
43+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
44+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

.gitignore

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
node_modules
22
/lib
3+
/fixtures/*/lib
4+
/packages/*/lib
5+
/**/*.tsbuildinfo
36
/dist
4-
/custom-elements.json
7+
custom-elements.json
8+
!/docs/assets/custom-elements.json
59
docs/_merged_data/
610
docs/_merged_assets/
711
docs/_merged_includes/

docs/assets/custom-elements.json

+12-12
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"modules": [
55
{
66
"kind": "javascript-module",
7-
"path": "src/fixtures/expansion-panel.ts",
7+
"path": "src/expansion-panel.ts",
88
"declarations": [
99
{
1010
"kind": "class",
@@ -257,22 +257,22 @@
257257
"name": "ExpansionPanel",
258258
"declaration": {
259259
"name": "ExpansionPanel",
260-
"module": "src/fixtures/expansion-panel.ts"
260+
"module": "src/expansion-panel.ts"
261261
}
262262
},
263263
{
264264
"kind": "custom-element-definition",
265265
"name": "expansion-panel",
266266
"declaration": {
267267
"name": "ExpansionPanel",
268-
"module": "src/fixtures/expansion-panel.ts"
268+
"module": "src/expansion-panel.ts"
269269
}
270270
}
271271
]
272272
},
273273
{
274274
"kind": "javascript-module",
275-
"path": "src/fixtures/fancy-accordion.ts",
275+
"path": "src/fancy-accordion.ts",
276276
"declarations": [
277277
{
278278
"kind": "class",
@@ -424,22 +424,22 @@
424424
"name": "FancyAccordion",
425425
"declaration": {
426426
"name": "FancyAccordion",
427-
"module": "src/fixtures/fancy-accordion.ts"
427+
"module": "src/fancy-accordion.ts"
428428
}
429429
},
430430
{
431431
"kind": "custom-element-definition",
432432
"name": "fancy-accordion",
433433
"declaration": {
434434
"name": "FancyAccordion",
435-
"module": "src/fixtures/fancy-accordion.ts"
435+
"module": "src/fancy-accordion.ts"
436436
}
437437
}
438438
]
439439
},
440440
{
441441
"kind": "javascript-module",
442-
"path": "src/fixtures/intl-currency.ts",
442+
"path": "src/intl-currency.ts",
443443
"declarations": [
444444
{
445445
"kind": "class",
@@ -520,22 +520,22 @@
520520
"name": "IntlCurrency",
521521
"declaration": {
522522
"name": "IntlCurrency",
523-
"module": "src/fixtures/intl-currency.ts"
523+
"module": "src/intl-currency.ts"
524524
}
525525
},
526526
{
527527
"kind": "custom-element-definition",
528528
"name": "intl-currency",
529529
"declaration": {
530530
"name": "IntlCurrency",
531-
"module": "src/fixtures/intl-currency.ts"
531+
"module": "src/intl-currency.ts"
532532
}
533533
}
534534
]
535535
},
536536
{
537537
"kind": "javascript-module",
538-
"path": "src/fixtures/progress-bar.ts",
538+
"path": "src/progress-bar.ts",
539539
"declarations": [
540540
{
541541
"kind": "class",
@@ -745,15 +745,15 @@
745745
"name": "ProgressBar",
746746
"declaration": {
747747
"name": "ProgressBar",
748-
"module": "src/fixtures/progress-bar.ts"
748+
"module": "src/progress-bar.ts"
749749
}
750750
},
751751
{
752752
"kind": "custom-element-definition",
753753
"name": "progress-bar",
754754
"declaration": {
755755
"name": "ProgressBar",
756-
"module": "src/fixtures/progress-bar.ts"
756+
"module": "src/progress-bar.ts"
757757
}
758758
}
759759
]

docs/docs/api/elements.md

+15-9
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ import 'api-viewer-element';
2424
A custom element that only provides API docs (no live playground):
2525

2626
```js
27-
import 'api-viewer-element/lib/api-docs.js';
27+
import '@api-viewer/docs';
2828
```
2929

3030
### `<api-demo>` element
3131

3232
A custom element that only provides live playground (no API docs):
3333

3434
```js
35-
import 'api-viewer-element/lib/api-demo.js';
35+
import '@api-viewer/demo';
3636
```
3737

3838
Note: the default entrypoint shares most of the code with both `<api-docs>` and `<api-demo>`.
@@ -54,8 +54,8 @@ If you don't need [`<template>` support](../templates/) in the live demo, feel f
5454
API documentation does not use templates.
5555

5656
```js
57-
import { ApiViewerBase } from 'api-viewer-element/lib/api-viewer-base.js';
58-
import { setTemplates } from 'api-viewer-element/lib/lib/utils.js';
57+
import { ApiViewerBase } from 'api-viewer-element/lib/base.js';
58+
import { setTemplates } from '@api-viewer/common/lib/templates.js';
5959
import { css } from 'lit';
6060

6161
class CustomViewer extends ApiViewerBase {
@@ -71,7 +71,10 @@ class CustomViewer extends ApiViewerBase {
7171
}
7272

7373
setTemplates(templates) {
74-
setTemplates(this._id, templates || Array.from(this.querySelectorAll('template')));
74+
setTemplates(
75+
this._id,
76+
templates || Array.from(this.querySelectorAll('template'))
77+
);
7578
}
7679
}
7780

@@ -83,7 +86,7 @@ customElements.define('custom-viewer', CustomViewer);
8386
A class that you can use to create your own version of `<api-docs>`.
8487

8588
```js
86-
import { ApiDocsBase } from 'api-viewer-element/lib/api-docs-base.js';
89+
import { ApiDocsBase } from '@api-viewer/docs/lib/base.js';
8790
import { css } from 'lit';
8891

8992
class CustomDocs extends ApiDocsBase {
@@ -102,8 +105,8 @@ customElements.define('custom-docs', CustomDocs);
102105
A class that you can use to create your own version of `<api-demo>`.
103106

104107
```js
105-
import { ApiDemoBase } from 'api-viewer-element/lib/api-demo-base.js';
106-
import { setTemplates } from 'api-viewer-element/lib/lib/utils.js';
108+
import { ApiDemoBase } from '@api-viewer/demo/lib/base.js';
109+
import { setTemplates } from '@api-viewer/common/lib/templates.js';
107110
import { css } from 'lit';
108111

109112
class CustomDemo extends ApiDemoBase {
@@ -119,7 +122,10 @@ class CustomDemo extends ApiDemoBase {
119122
}
120123

121124
setTemplates(templates) {
122-
setTemplates(this._id, templates || Array.from(this.querySelectorAll('template')));
125+
setTemplates(
126+
this._id,
127+
templates || Array.from(this.querySelectorAll('template'))
128+
);
123129
}
124130
}
125131

docs/docs/examples/api-demo.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
```js script
44
import { html } from '@mdjs/mdjs-preview';
5-
import '../../../lib/api-demo.js';
6-
import '../../../lib/fixtures/expansion-panel.js';
7-
import '../../../lib/fixtures/fancy-accordion.js';
8-
import '../../../lib/fixtures/intl-currency.js';
9-
import '../../../lib/fixtures/progress-bar.js';
5+
import '../../../packages/api-demo/lib/api-demo.js';
6+
import '../../../fixtures/lit/lib/expansion-panel.js';
7+
import '../../../fixtures/lit/lib/fancy-accordion.js';
8+
import '../../../fixtures/lit/lib/intl-currency.js';
9+
import '../../../fixtures/lit/lib/progress-bar.js';
1010
```
1111

1212
```html preview-story

docs/docs/examples/api-docs.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
```js script
44
import { html } from '@mdjs/mdjs-preview';
5-
import '../../../lib/api-docs.js';
5+
import '../../../packages/api-docs/lib/api-docs.js';
66
```
77

88
```html preview-story

docs/docs/examples/api-viewer.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
```js script
44
import { html } from '@mdjs/mdjs-preview';
5-
import '../../../lib/api-viewer.js';
6-
import '../../../lib/fixtures/expansion-panel.js';
7-
import '../../../lib/fixtures/fancy-accordion.js';
8-
import '../../../lib/fixtures/intl-currency.js';
9-
import '../../../lib/fixtures/progress-bar.js';
5+
import '../../../packages/api-viewer/lib/api-viewer.js';
6+
import '../../../fixtures/lit/lib/expansion-panel.js';
7+
import '../../../fixtures/lit/lib/fancy-accordion.js';
8+
import '../../../fixtures/lit/lib/intl-currency.js';
9+
import '../../../fixtures/lit/lib/progress-bar.js';
1010
```
1111

1212
```html preview-story

docs/docs/examples/theming.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
```js script
44
import { html } from '@mdjs/mdjs-preview';
5-
import '../../../lib/api-viewer.js';
6-
import '../../../lib/fixtures/expansion-panel.js';
7-
import '../../../lib/fixtures/fancy-accordion.js';
8-
import '../../../lib/fixtures/intl-currency.js';
9-
import '../../../lib/fixtures/progress-bar.js';
5+
import '../../../packages/api-viewer/lib/api-viewer.js';
6+
import '../../../fixtures/lit/lib/expansion-panel.js';
7+
import '../../../fixtures/lit/lib/fancy-accordion.js';
8+
import '../../../fixtures/lit/lib/intl-currency.js';
9+
import '../../../fixtures/lit/lib/progress-bar.js';
1010
```
1111

1212
```html preview-story

fixtures/lit/package.json

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"name": "@api-viewer-fixtures/lit",
3+
"version": "0.0.0",
4+
"private": true,
5+
"scripts": {
6+
"analyze": "cem analyze --litelement --globs 'src/*.ts'"
7+
},
8+
"dependencies": {
9+
"lit": "^2.0.0",
10+
"tslib": "^2.3.1"
11+
},
12+
"customElements": "custom-elements.json"
13+
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

fixtures/lit/tsconfig.json

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Don't edit this file directly. It is generated by /scripts/update-package-configs.ts
2+
3+
{
4+
"extends": "../../tsconfig.base.json",
5+
"compilerOptions": {
6+
"module": "ESNext",
7+
"outDir": "./lib",
8+
"rootDir": "./src",
9+
"composite": true
10+
},
11+
"references": [],
12+
"include": [
13+
"src"
14+
],
15+
"exclude": [
16+
"lib"
17+
]
18+
}

0 commit comments

Comments
 (0)