Skip to content

Commit

Permalink
chore(mocks): generate and publish types + setup wireit
Browse files Browse the repository at this point in the history
  • Loading branch information
daKmoR committed Jul 3, 2023
1 parent 3fae385 commit 78f7639
Show file tree
Hide file tree
Showing 25 changed files with 239 additions and 74 deletions.
5 changes: 5 additions & 0 deletions .changeset/sour-grapes-rest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@web/mocks': patch
---

Publish Types
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ demo
CHANGELOG.md
.changeset
_site
dist-types
3 changes: 3 additions & 0 deletions .github/workflows/canary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ jobs:
cache: 'npm'
registry-url: 'https://registry.npmjs.org'

# Set up GitHub Actions caching for Wireit.
- uses: google/wireit@setup-github-actions-caching/v1

- name: Install Dependencies
run: npm ci

Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ jobs:
cache: 'npm'
registry-url: 'https://registry.npmjs.org'

# Set up GitHub Actions caching for Wireit.
- uses: google/wireit@setup-github-actions-caching/v1

- name: Install Dependencies
run: npm ci

Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/verify-browserstack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ jobs:
node-version: '18'
cache: 'npm'

- name: Install dependencies
# Set up GitHub Actions caching for Wireit.
- uses: google/wireit@setup-github-actions-caching/v1

- name: Install Dependencies
run: npm ci

- name: Build packages
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/verify-node.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ jobs:
- name: Install Playwright dependencies
run: npx playwright install-deps

- name: Install dependencies
# Set up GitHub Actions caching for Wireit.
- uses: google/wireit@setup-github-actions-caching/v1

- name: Install Dependencies
run: npm ci

- name: Build packages
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/verify-saucelabs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ jobs:
node-version: '18'
cache: 'npm'

- name: Install dependencies
# Set up GitHub Actions caching for Wireit.
- uses: google/wireit@setup-github-actions-caching/v1

- name: Install Dependencies
run: npm ci

- name: Build packages
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/verify-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ jobs:
- name: Install Playwright dependencies
run: npx playwright install-deps

- name: Install dependencies
# Set up GitHub Actions caching for Wireit.
- uses: google/wireit@setup-github-actions-caching/v1

- name: Install Dependencies
run: npm ci

- name: Build
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ yarn.lock
packages/*/yarn.lock

## build output
dist-types
.wireit
/dist
/packages/*/dist
tsconfig.tsbuildinfo
Expand Down
50 changes: 48 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 21 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"node": ">=16.0.0"
},
"scripts": {
"build": "rimraf --glob packages/*/tsconfig.tsbuildinfo && tsc --build",
"build": "rimraf --glob packages/*/tsconfig.tsbuildinfo && tsc --build && npm run types",
"build:production": "node scripts/workspaces-scripts-bin.mjs build:production",
"build:site": "npm run build && rocket build",
"build:watch": "rimraf --glob packages/*/tsconfig.tsbuildinfo && tsc --build --watch",
Expand All @@ -30,6 +30,7 @@
"search": "rocket search",
"start": "rocket start",
"start:build": "node packages/dev-server/dist/bin.js --root-dir _site --open",
"types": "wireit",
"test": "npm run test:node && npm run test:browser && node scripts/workspaces-scripts-bin.mjs test:ci",
"test:browser": "node packages/test-runner/dist/bin.js \"packages/*/test-browser/**/*.test.{js,ts}\"",
"test:node": "mocha \"packages/!(*test-runner-selenium|*test-runner-webdriver)/test/**/*.test.{ts,js,mjs,cjs}\"",
Expand Down Expand Up @@ -73,17 +74,8 @@
"rimraf": "^4.4.1",
"rollup": "^3.15.0",
"ts-node": "^10.4.0",
"typescript": "~5.0.4"
},
"overrides": {
"@lion/accordion": "^0.11.1",
"@lion/combobox": "^0.11.1",
"@lion/core": "^0.24.0",
"@lion/form-core": "^0.18.3",
"@lion/overlays": "^0.33.2",
"@mdjs/core": "^0.9.0",
"@mdjs/mdjs-preview": "^0.5.5",
"@rocket/drawer": "^0.1.4"
"typescript": "~5.0.4",
"wireit": "^0.9.5"
},
"eslintConfig": {
"parser": "@typescript-eslint/parser",
Expand Down Expand Up @@ -125,12 +117,29 @@
"exit": true,
"retries": 3
},
"overrides": {
"@lion/accordion": "^0.11.1",
"@lion/combobox": "^0.11.1",
"@lion/core": "^0.24.0",
"@lion/form-core": "^0.18.3",
"@lion/overlays": "^0.33.2",
"@mdjs/core": "^0.9.0",
"@mdjs/mdjs-preview": "^0.5.5",
"@rocket/drawer": "^0.1.4"
},
"prettier": {
"singleQuote": true,
"arrowParens": "avoid",
"printWidth": 100,
"trailingComma": "all"
},
"wireit": {
"types": {
"dependencies": [
"./packages/mocks:types"
]
}
},
"workspaces": [
"packages/*",
"integration/*"
Expand Down
2 changes: 1 addition & 1 deletion packages/mocks/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ worker.start({
/**
* Mock the given mocked routes using a Service Worker.
*
* @param {Array<Array<Mock>|Mock>} mocks
* @param {import('./types.js').Mock[]} mocks
*/
function registerMockRoutes(...mocks) {
_registerMockRoutes(worker, bypassServiceWorker, ...mocks);
Expand Down
38 changes: 38 additions & 0 deletions packages/mocks/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,60 @@ const VERSION = Symbol.for('msw-integration-layer::version');
* and it's import should be pure and non-sideeffectful.
*/
export const http = {
/**
* @param {string} endpoint
* @param {import('./types.js').handler} handler
* @returns {import('./types.js').Mock}
*/
get: (endpoint, handler) => {
return { [VERSION]: '1.x.x', method: 'get', endpoint, handler };
},
/**
* @param {string} endpoint
* @param {import('./types.js').handler} handler
* @returns {import('./types.js').Mock}
*/
post: (endpoint, handler) => {
return { [VERSION]: '1.x.x', method: 'post', endpoint, handler };
},
/**
* @param {string} endpoint
* @param {import('./types.js').handler} handler
* @returns {import('./types.js').Mock}
*/
put: (endpoint, handler) => {
return { [VERSION]: '1.x.x', method: 'put', endpoint, handler };
},
/**
* @param {string} endpoint
* @param {import('./types.js').handler} handler
* @returns {import('./types.js').Mock}
*/
patch: (endpoint, handler) => {
return { [VERSION]: '1.x.x', method: 'patch', endpoint, handler };
},
/**
* @param {string} endpoint
* @param {import('./types.js').handler} handler
* @returns {import('./types.js').Mock}
*/
delete: (endpoint, handler) => {
return { [VERSION]: '1.x.x', method: 'delete', endpoint, handler };
},
/**
* @param {string} endpoint
* @param {import('./types.js').handler} handler
* @returns {import('./types.js').Mock}
*/
options: (endpoint, handler) => {
return { [VERSION]: '1.x.x', method: 'options', endpoint, handler };
},
/**
* @param {string} endpoint
* @param {import('./types.js').handler} handler
* @returns {import('./types.js').Mock}
*/
head: (endpoint, handler) => {
return { [VERSION]: '1.x.x', method: 'head', endpoint, handler };
},
};
4 changes: 2 additions & 2 deletions packages/mocks/node.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { setupServer } from 'msw/node';
import { _registerMockRoutes } from './_registerMockRoutes.js';
import { _registerMockRoutes } from './registerMockRoutes.js';

export const server = setupServer();
server.listen();

/**
* Mock the given mocked routes using a Service Worker.
*
* @param {Array<Array<Mock>|Mock>} mocks
* @param {import('./types.js').Mock[]} mocks
*/
export function registerMockRoutes(...mocks) {
_registerMockRoutes(server, false, ...mocks);
Expand Down
Loading

0 comments on commit 78f7639

Please sign in to comment.