Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeScript Docs #46

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
build/**
dist/**
coverage/**
*.d.ts
3 changes: 2 additions & 1 deletion .eslintrc.js → .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module.exports = {
plugins: ['svelte3', 'typescript'],
plugins: ['svelte3', '@typescript-eslint'],
parser: '@typescript-eslint/parser',
rules: {
'no-console': 0,
'no-undefined': 1,
Expand Down
32 changes: 32 additions & 0 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: GitHub Pages

on:
push:
branches:
- main
pull_request:

jobs:
deploy:
runs-on: ubuntu-22.04
permissions:
contents: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
steps:
- uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18.x.x

- run: yarn
- run: yarn typedoc src/index.ts

- name: Deploy
uses: peaceiris/actions-gh-pages@v3
if: github.ref == 'refs/heads/main'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs

1 change: 1 addition & 0 deletions .github/workflows/tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
- run: yarn
- run: yarn build
- run: yarn tsc
- uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_TOKEN }}
Expand Down
16 changes: 13 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Unit tests
uses: actions/setup-node@v3
with:
node-version: 16.x.x
node-version: 18.x.x
- run: yarn
- run: yarn test
- name: cypress
Expand All @@ -38,17 +38,27 @@ jobs:
- name: Lints
uses: actions/setup-node@v3
with:
node-version: 16.x.x
node-version: 18.x.x
- run: yarn
- run: yarn lint
typecheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Type Check
uses: actions/setup-node@v3
with:
node-version: 18.x.x
- run: yarn
- run: yarn typecheck
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Lints
uses: actions/setup-node@v3
with:
node-version: 16.x.x
node-version: 18.x.x
- run: yarn
- run: yarn build

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ cypress/videos
dist
build
public
docs
.idea
test-report.xml

Expand Down
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ test-report.xml
# misc folders
coverage
dist
docs
public
recipes
cypress
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## 0.2.0 - JSDoc type coverage, docs site

- chore: cover codebase with JSDoc types
- chore: add typecheck CI step
- feat: support ESM/CommonJS `jambox.config.js` in config files
- feat: build & publish TS types
- fix: wait for full reset when cwd is changed via api

## 0.1.3 - Match paths containing dots, serialize browser config values

- fix: match pathnames with dot('.') literals in them
Expand Down
2 changes: 1 addition & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
export default {
plugins: [],
presets: [
[
Expand Down
8 changes: 3 additions & 5 deletions cypress-node-events.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const fetch = require('node-fetch');
const waitOn = require('wait-on');
import fetch from 'node-fetch';
import waitOn from 'wait-on';

function nodeEvents(on) {
export default function nodeEvents(on) {
on('task', {
jambox: {
// Configure Jambox with a dynamic config during a test
Expand Down Expand Up @@ -31,5 +31,3 @@ function nodeEvents(on) {
},
});
}

module.exports = nodeEvents;
14 changes: 9 additions & 5 deletions cypress.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
const fetch = require('node-fetch');
const { defineConfig } = require('cypress');
const webpackConfig = require('./webpack.config.js');
// @ts-check
import fetch from 'node-fetch';
import { defineConfig } from 'cypress';
import webpackConfig from './webpack.config.js';
import nodeEvents from './cypress-node-events.js';

module.exports = defineConfig({
const config = defineConfig({
viewportHeight: 720,
viewportWidth: 1280,
chromeWebSecurity: false,
Expand All @@ -15,7 +17,7 @@ module.exports = defineConfig({
webpackConfig,
},
setupNodeEvents(on, config) {
require('./cypress-node-events')(on);
nodeEvents(on);

// Shutdown the server after `yarn cypress run --component completes
// This ensures that c8 outputs the lcov.info file properly
Expand All @@ -26,3 +28,5 @@ module.exports = defineConfig({
},
},
});

export default config;
26 changes: 1 addition & 25 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
@@ -1,25 +1 @@
// ***********************************************
// This example commands.js shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
//
//
// -- This is a parent command --
// Cypress.Commands.add('login', (email, password) => { ... })
//
//
// -- This is a child command --
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
// empty
28 changes: 2 additions & 26 deletions cypress/support/component.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,4 @@
// ***********************************************************
// This example support/component.js is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************
import './commands.js';
import { mount } from 'cypress/svelte';

// Import commands.js using ES2015 syntax:
// import './commands';

// Alternatively you can use CommonJS syntax:
// require('./commands')

// import { mount } from 'cypress/svelte/dist/cypress-svelte.esm-bundler.js';
require('./commands');
const { mount } = require('cypress/svelte');
Cypress.Commands.add('mount', mount);

// Example use:
// cy.mount(MyComponent)
2 changes: 1 addition & 1 deletion e2e-backend.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import http from 'http';
import tinyServer from './src/utils/tiny-server.mjs';
import jamboxServer from './src/server/index.mjs';
import { enable as enableDiagnostics } from './src/diagnostics.js';
import { enable as enableDiagnostics } from './src/diagnostics.cjs';

enableDiagnostics();

Expand Down
8 changes: 2 additions & 6 deletions ext/Api.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
// @ts-check
import Observable from 'zen-observable';
import { debounce } from './nodash';

/**
* @typedef {import('./types').Subscribtion} Subscribtion
*/
import { debounce } from './nodash.js';

const WEBSOCKET_RETRY_TIMER = 3000;

export default class API {
/**
* @type {?Subscribtion}
* @type {?ZenObservable.Subscription}
* */
#sub;
/**
Expand Down
2 changes: 1 addition & 1 deletion ext/App.cy.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import API from './Api';
import API from './Api.js';
import App from './App.svelte';

let api;
Expand Down
2 changes: 1 addition & 1 deletion ext/Cache.cy.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import API from './Api';
import API from './Api.js';
import App from './App.svelte';

let api;
Expand Down
2 changes: 1 addition & 1 deletion ext/manifest.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
export default {
name: 'Jambox',
description: 'Examine and edit proxied requests',
version: '0.0.2',
Expand Down
2 changes: 1 addition & 1 deletion ext/panel.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import App from './App.svelte';
import API from './Api';
import API from './Api.js';

const boot = async () => {
const api = await API.create();
Expand Down
1 change: 0 additions & 1 deletion ext/types.d.ts

This file was deleted.

2 changes: 1 addition & 1 deletion jam-server.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import server from './src/server/index.mjs';
import fs from 'fs';
import fetch from 'node-fetch';
import Tail from 'tail-file';
import { enable as enableDiagnostics } from './src/diagnostics.js';
import { enable as enableDiagnostics } from './src/diagnostics.cjs';

enableDiagnostics();

Expand Down
2 changes: 1 addition & 1 deletion jam.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env node
import entrypoint from './src/entrypoint.mjs';
import * as constants from './src/constants.mjs';
import { enable as enableDiagnostics } from './src/diagnostics.js';
import { enable as enableDiagnostics } from './src/diagnostics.cjs';

enableDiagnostics();

Expand Down
7 changes: 6 additions & 1 deletion jambox.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-check
/**
* This config is used for integration tests
*
Expand All @@ -6,7 +7,11 @@
* - Causes .jambox/default.tape.zip to be written
* - Leave .jambox/default.tape.zip empty after integration tests
*/
module.exports = {

/**
* @type {import('./src/index.js').FileConfig}
*/
export default {
blockNetworkRequests: false,
forward: {
'http://jambox-test.com': {
Expand Down
8 changes: 3 additions & 5 deletions manifest-plugin.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const prettier = require('prettier');
const manifest = require('./ext/manifest');
import prettier from 'prettier';
import manifest from './ext/manifest.js';

class ManifestPlugin {
export default class ManifestPlugin {
apply(compiler) {
compiler.hooks.make.tap('ManifestPlugin', (compilation) => {
const fileName = 'manifest.json';
Expand All @@ -20,5 +20,3 @@ class ManifestPlugin {
});
}
}

module.exports = ManifestPlugin;
Loading