Compare commits

...

17 Commits

Author SHA1 Message Date
Thomas Allmer
fdf4cd6723 feat: update to lit3 to fix ssr 2024-02-24 15:52:11 +01:00
Thomas Allmer
74b2b35812 feat(building-rollup): update to rollup v3 + v3 plugins 2023-06-27 17:46:06 +02:00
Nathan Brown
685e6fd9b4 fix(building-rollup): resolve json5 security vulnerability 2023-06-08 22:03:57 +02:00
Thomas Allmer
ecfa631367 chore: add patch file for @web/dev-server 2022-10-31 22:14:42 +01:00
Thomas Allmer
80ff4be34a feat: setup wireit and use it for the types generation 2022-10-31 22:14:42 +01:00
Thomas Allmer
3fd736c213 chore: update lock files 2022-10-28 21:43:56 +02:00
Thomas Allmer
f3cc3b8050 chore: update to typescript 4.8.4 2022-10-28 21:22:06 +02:00
Thomas Allmer
a049a82141 chore: use npm workspaces 2022-10-28 15:45:00 +02:00
Davie
a868ff13e4 Update 80--hydration.rocket.md
Grammar edit from none to non-chromium browser(s)
2022-10-12 23:06:34 +02:00
github-actions[bot]
5f4a86b1a8 Version Packages 2022-10-06 10:05:15 +02:00
Thomas Allmer
79e6f0df33 Create tame-tigers-marry.md 2022-10-06 09:32:19 +02:00
Matsu
04621c3f16 Update the error message on degit action 2022-10-06 09:32:19 +02:00
Nathan Brown
1cd9508384 docs: site cleanup
Remove extraneous words and correct misphrasings.
2022-09-10 10:34:13 +02:00
github-actions[bot]
c8082fbac8 Version Packages 2022-08-24 11:37:04 +02:00
Thomas Allmer
68e05f4d4a feat(check-html-links): handle as internal if starts with a provided absolute base url 2022-08-24 11:33:10 +02:00
Thomas Allmer
660f64c320 fix(launch): change the default git branch to main 2022-08-24 11:33:10 +02:00
Jorge del Casar
97d5fb2040 feat(check-html-links): add external link validation 2022-08-24 11:33:10 +02:00
167 changed files with 19487 additions and 9319 deletions

View File

@@ -0,0 +1,6 @@
---
'@rocket/building-rollup': minor
'@rocket/cli': minor
---
Update to Rollup v3 + all plugins that require it

View File

@@ -0,0 +1,5 @@
---
'@rocket/building-rollup': patch
---
fix json5 security vulnerability

View File

@@ -13,6 +13,10 @@ __output-dev
docs/_merged* docs/_merged*
*-mdjs-generated.js *-mdjs-generated.js
*-converted-md-source.js
*-converted-md.js
__example_site-for-check-website
# sanity example has a separate backend that is unrelated to Rocket # sanity example has a separate backend that is unrelated to Rocket
# therefore it does not need to follow it code rules # therefore it does not need to follow it code rules

View File

@@ -12,45 +12,29 @@ jobs:
name: Release name: Release
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: google/wireit@setup-github-actions-caching/v1
- name: Checkout Repo - name: Checkout Repo
uses: actions/checkout@master uses: actions/checkout@master
with: with:
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits # This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
fetch-depth: 0 fetch-depth: 0
- name: Setup Node.js 14.x - name: Setup Node.js 18.x
uses: actions/setup-node@master uses: actions/setup-node@master
with: with:
node-version: 14.x node-version: 18.x
registry-url: 'https://registry.npmjs.org' registry-url: 'https://registry.npmjs.org'
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v2
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install Dependencies - name: Install Dependencies
run: yarn --frozen-lockfile run: npm ci
- name: Build Packages
run: yarn build:packages
- name: Build Types
run: yarn types
- name: Create Release Pull Request or Publish to npm - name: Create Release Pull Request or Publish to npm
id: changesets id: changesets
uses: changesets/action@master uses: changesets/action@master
with: with:
# This expects you to have a script called release which does a build for your packages and calls changeset publish # This expects you to have a script called release which does a build for your packages and calls changeset publish
publish: yarn release publish: npm run release
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

View File

@@ -8,8 +8,9 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
matrix: matrix:
node-version: [16.x] node-version: [18.x]
steps: steps:
- uses: google/wireit@setup-github-actions-caching/v1
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Setup Node ${{ matrix.node-version }} - name: Setup Node ${{ matrix.node-version }}
@@ -17,20 +18,8 @@ jobs:
with: with:
node-version: ${{ matrix.node-version }} node-version: ${{ matrix.node-version }}
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v2
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies - name: Install dependencies
run: yarn --frozen-lockfile run: npm ci
- name: Install Playwright dependencies - name: Install Playwright dependencies
run: npx playwright install-deps run: npx playwright install-deps
@@ -38,40 +27,8 @@ jobs:
- name: Install Playwright - name: Install Playwright
run: npx playwright install run: npx playwright install
- name: Build Packages
run: yarn build:packages
- name: Lint - name: Lint
run: yarn lint run: npm run lint
- name: Test - name: Test
run: yarn test run: npm run test
# verify-windows:
# name: Verify windows
# runs-on: windows-latest
# steps:
# - uses: actions/checkout@v2
# - name: Setup Node 12.x
# uses: actions/setup-node@v1
# with:
# node-version: 12.x
# - name: Get yarn cache directory path
# id: yarn-cache-dir-path
# run: echo "::set-output name=dir::$(yarn cache dir)"
# - uses: actions/cache@v2
# id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
# with:
# path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
# key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
# restore-keys: |
# ${{ runner.os }}-yarn-
# - name: Install dependencies
# run: yarn --frozen-lockfile
# - name: Test
# run: yarn test

8
.gitignore vendored
View File

@@ -12,21 +12,16 @@ coverage/
## npm ## npm
node_modules node_modules
npm-debug.log npm-debug.log
yarn-error.log
## temp folders ## temp folders
/.tmp/ /.tmp/
## we prefer yarn.lock
package-lock.json
## lock files in packages we do not need to save
packages/*/yarn.lock
## build output ## build output
dist dist
dist-types dist-types
stats.html stats.html
*.tsbuildinfo *.tsbuildinfo
.wireit
# Rocket Search # Rocket Search
rocket-search-index.json rocket-search-index.json
@@ -49,3 +44,4 @@ docs_backup
## Local playground ## Local playground
examples/testing examples/testing
__example_site-for-check-website

View File

@@ -8,5 +8,5 @@
"**/*-mdjs-generated.js": true, "**/*-mdjs-generated.js": true,
"**/dist-types": true, "**/dist-types": true,
}, },
"editor.experimental.stickyScroll.enabled": true "editor.stickyScroll.enabled": true
} }

View File

@@ -32,10 +32,10 @@ git checkout -b my-awesome-fix
## Preparing Your Local Environment for Development ## Preparing Your Local Environment for Development
Now that you have cloned the repository, ensure you have [yarn](https://classic.yarnpkg.com/lang/en/) installed, then run the following commands to set up the development environment. Now that you have cloned the repository, ensure you have [node](https://nodejs.org/) installed, then run the following commands to set up the development environment.
```shell ```shell
yarn install npm install
``` ```
This will download and install all packages needed. This will download and install all packages needed.
@@ -50,7 +50,7 @@ If you're making cross-package changes, you need to compile the TypeScript code.
### Running Tests ### Running Tests
To run the tests of a package, it's recommended to `cd` into the package directory and then using `yarn test` to run them. This way you're only running tests of that specific package. To run the tests of a package, it's recommended to `cd` into the package directory and then using `npm run test` to run them. This way you're only running tests of that specific package.
### Integration Testing ### Integration Testing
@@ -58,7 +58,7 @@ To see how your changes integrate with everything together you can use the `test
## Adding New Packages ## Adding New Packages
For all projects the tsconfig/jsconfig configuration files are auto generated. You need to add an entry to the [./workspace-packages.ts](./workspace-packages.ts) to let it generate a config for you. After adding an entry, run `yarn update-package-configs` to generate the files for you. For all projects the tsconfig/jsconfig configuration files are auto generated. You need to add an entry to the [./workspace-packages.ts](./workspace-packages.ts) to let it generate a config for you. After adding an entry, run `npm run update-package-configs` to generate the files for you.
## Creating a Changeset ## Creating a Changeset
@@ -70,7 +70,7 @@ This documents your intent to release, and allows you to specify a message that
Run Run
```shell ```shell
yarn changeset npm run changeset
``` ```
And use the menu to select for which packages you need a release, and then select what kind of release. For the release type, we follow [Semantic Versioning](https://semver.org/), so please take a look if you're unfamiliar. And use the menu to select for which packages you need a release, and then select what kind of release. For the release type, we follow [Semantic Versioning](https://semver.org/), so please take a look if you're unfamiliar.

View File

@@ -3,8 +3,6 @@ node_modules/
# logs # logs
npm-debug.log* npm-debug.log*
yarn-debug.log*
yarn-error.log*
# environment variables # environment variables
.env .env

View File

@@ -14,7 +14,7 @@
"@rocket/cli": "^0.20.0", "@rocket/cli": "^0.20.0",
"@rocket/engine": "^0.2.0", "@rocket/engine": "^0.2.0",
"@webcomponents/template-shadowroot": "^0.1.0", "@webcomponents/template-shadowroot": "^0.1.0",
"lit": "^2.3.0" "lit": "^3.0.0"
}, },
"@rocket/template-name": "Hydration Starter", "@rocket/template-name": "Hydration Starter",
"imports": { "imports": {

View File

@@ -3,8 +3,6 @@ node_modules/
# logs # logs
npm-debug.log* npm-debug.log*
yarn-debug.log*
yarn-error.log*
# environment variables # environment variables
.env .env

View File

@@ -18,7 +18,7 @@
"devDependencies": { "devDependencies": {
"@rocket/cli": "^0.20.0", "@rocket/cli": "^0.20.0",
"@rocket/engine": "^0.2.0", "@rocket/engine": "^0.2.0",
"lit": "^2.3.0" "lit": "^3.0.0"
}, },
"@rocket/template-name": "Blog Starter" "@rocket/template-name": "Blog Starter"
} }

View File

@@ -3,8 +3,6 @@ node_modules/
# logs # logs
npm-debug.log* npm-debug.log*
yarn-debug.log*
yarn-error.log*
# environment variables # environment variables
.env .env

View File

@@ -13,7 +13,7 @@
"devDependencies": { "devDependencies": {
"@rocket/cli": "^0.20.0", "@rocket/cli": "^0.20.0",
"@rocket/engine": "^0.2.0", "@rocket/engine": "^0.2.0",
"lit": "^2.3.0" "lit": "^3.0.0"
}, },
"@rocket/template-name": "Minimal Starter" "@rocket/template-name": "Minimal Starter"
} }

View File

@@ -1,4 +1,2 @@
/dist /dist
/node_modules /node_modules
yarn.lock

View File

@@ -3,7 +3,6 @@
"private": true, "private": true,
"version": "1.0.0", "version": "1.0.0",
"description": "", "description": "",
"main": "package.json",
"author": "Jaydan Urwin <jaydan@jaydanurwin.com>", "author": "Jaydan Urwin <jaydan@jaydanurwin.com>",
"license": "UNLICENSED", "license": "UNLICENSED",
"scripts": { "scripts": {

View File

@@ -3,8 +3,6 @@ node_modules/
# logs # logs
npm-debug.log* npm-debug.log*
yarn-debug.log*
yarn-error.log*
# environment variables # environment variables
.env .env

View File

@@ -18,7 +18,7 @@
"@sanity/client": "^3.1.0", "@sanity/client": "^3.1.0",
"@sanity/image-url": "^1.0.1", "@sanity/image-url": "^1.0.1",
"dotenv": "^16.0.0", "dotenv": "^16.0.0",
"lit": "^2.3.0" "lit": "^3.0.0"
}, },
"@rocket/template-name": "Sanity Minimal Starter" "@rocket/template-name": "Sanity Minimal Starter"
} }

View File

@@ -3,8 +3,6 @@ node_modules/
# logs # logs
npm-debug.log* npm-debug.log*
yarn-debug.log*
yarn-error.log*
# environment variables # environment variables
.env .env

View File

@@ -15,7 +15,7 @@
"@rocket/components": "^0.2.0", "@rocket/components": "^0.2.0",
"@rocket/engine": "^0.2.0", "@rocket/engine": "^0.2.0",
"@rocket/spark": "^0.2.0", "@rocket/spark": "^0.2.0",
"lit": "^2.3.0" "lit": "^3.0.0"
}, },
"@rocket/template-name": "Landing Page (@rocket/spark Theme)", "@rocket/template-name": "Landing Page (@rocket/spark Theme)",
"imports": { "imports": {

View File

@@ -3,8 +3,6 @@ node_modules/
# logs # logs
npm-debug.log* npm-debug.log*
yarn-debug.log*
yarn-error.log*
# environment variables # environment variables
.env .env

View File

@@ -15,7 +15,7 @@
"@rocket/engine": "^0.2.0", "@rocket/engine": "^0.2.0",
"@rocket/launch": "^0.21.0", "@rocket/launch": "^0.21.0",
"@rocket/search": "^0.7.0", "@rocket/search": "^0.7.0",
"lit": "^2.3.0" "lit": "^3.0.0"
}, },
"@rocket/template-name": "Documentation Website (@rocket/launch Theme)", "@rocket/template-name": "Documentation Website (@rocket/launch Theme)",
"imports": { "imports": {

18371
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -10,9 +10,9 @@
"scripts": { "scripts": {
"analyze": "run-s analyze:* format:*", "analyze": "run-s analyze:* format:*",
"analyze:analyze": "node scripts/workspaces-scripts-bin.mjs analyze", "analyze:analyze": "node scripts/workspaces-scripts-bin.mjs analyze",
"build": "npm run build:packages && npm run rocket:build", "build": "npm run rocket:build",
"build:packages": "node scripts/workspaces-scripts-bin.mjs build:package",
"build:site": "run-s analyze:* rocket:build", "build:site": "run-s analyze:* rocket:build",
"build:start": "npm run rocket:build && cd _site && npx http-server -o -p 9000",
"changeset": "changeset", "changeset": "changeset",
"debug": "web-test-runner --watch --config web-test-runner-chrome.config.mjs", "debug": "web-test-runner --watch --config web-test-runner-chrome.config.mjs",
"debug:firefox": "web-test-runner --watch --config web-test-runner-firefox.config.mjs", "debug:firefox": "web-test-runner --watch --config web-test-runner-firefox.config.mjs",
@@ -25,40 +25,35 @@
"lint:prettier": "node node_modules/prettier/bin-prettier.js \"**/*.{ts,js,mjs,cjs,md}\" --check --ignore-path .eslintignore", "lint:prettier": "node node_modules/prettier/bin-prettier.js \"**/*.{ts,js,mjs,cjs,md}\" --check --ignore-path .eslintignore",
"lint:types": "npm run types", "lint:types": "npm run types",
"lint:versions": "node scripts/lint-versions.js", "lint:versions": "node scripts/lint-versions.js",
"postinstall": "npm run setup", "postinstall": "npx patch-package",
"release": "changeset publish && yarn format", "preview": "node packages/cli/src/cli.js preview --open",
"release": "changeset publish && npm run format",
"rocket:build": "NODE_DEBUG=engine:rendering node --trace-warnings packages/cli/src/cli.js build", "rocket:build": "NODE_DEBUG=engine:rendering node --trace-warnings packages/cli/src/cli.js build",
"rocket:upgrade": "node packages/cli/src/cli.js upgrade", "rocket:upgrade": "node packages/cli/src/cli.js upgrade",
"search": "node packages/cli/src/cli.js search", "search": "node packages/cli/src/cli.js search",
"setup": "npm run setup:ts-configs",
"setup:patches": "npx patch-package",
"setup:ts-configs": "node scripts/generate-ts-configs.mjs",
"start:experimental": "NODE_DEBUG=engine:rendering node --no-warnings --experimental-loader ./packages/engine/src/litCssLoader.js packages/cli/src/cli.js start --open",
"start": "NODE_DEBUG=engine:rendering node --trace-warnings packages/cli/src/cli.js start --open", "start": "NODE_DEBUG=engine:rendering node --trace-warnings packages/cli/src/cli.js start --open",
"preview": "node packages/cli/src/cli.js preview --open", "start:experimental": "NODE_DEBUG=engine:rendering node --no-warnings --experimental-loader ./packages/engine/src/litCssLoader.js packages/cli/src/cli.js start --open",
"test": "yarn test:node && yarn test:web", "start:build": "cd _site && npx http-server -o -p 9000",
"test": "npm run test:node && npm run test:web",
"test:integration": "playwright test packages/*/test-node/*.spec.js --retries=3", "test:integration": "playwright test packages/*/test-node/*.spec.js --retries=3",
"test:node": "yarn test:unit && yarn test:integration", "test:node": "npm run test:unit && npm run test:integration",
"test:unit": "node --trace-warnings ./node_modules/.bin/mocha --require ./scripts/testMochaGlobalHooks.js \"packages/*/test-node/**/*.test.{ts,js,mjs,cjs}\" -- --timeout 8000 --reporter dot --exit", "test:unit": "node --trace-warnings ./node_modules/.bin/mocha --require ./scripts/testMochaGlobalHooks.js \"packages/*/test-node/**/*.test.{ts,js,mjs,cjs}\" -- --timeout 8000 --reporter dot --exit",
"test:web": "web-test-runner", "test:web": "web-test-runner",
"types": "run-s types:clear types:copy types:build", "types": "npm run types --workspaces --if-present",
"types:build": "tsc --build",
"types:clear": "rimraf packages/*/dist-types/",
"types:copy": "node scripts/workspaces-scripts-bin.mjs types:copy",
"update-dependency": "node scripts/update-dependency.js", "update-dependency": "node scripts/update-dependency.js",
"update-esm-entrypoints": "node scripts/update-esm-entrypoints.mjs && yarn format", "update-esm-entrypoints": "node scripts/update-esm-entrypoints.mjs && npm run format",
"update-package-configs": "node scripts/update-package-configs.mjs && yarn format", "update-package-configs": "node scripts/update-package-configs.mjs && npm run format",
"xprestart": "yarn analyze" "xprestart": "npm run analyze"
}, },
"dependencies": {},
"devDependencies": { "devDependencies": {
"@changesets/cli": "^2.20.0", "@changesets/cli": "^2.20.0",
"@custom-elements-manifest/analyzer": "^0.4.12", "@custom-elements-manifest/analyzer": "^0.4.12",
"@playwright/test": "^1.18.1",
"@open-wc/testing": "^3.1.2", "@open-wc/testing": "^3.1.2",
"@rollup/plugin-commonjs": "^17.0.0", "@playwright/test": "^1.18.1",
"@rollup/plugin-json": "^4.1.0", "@rollup/plugin-commonjs": "^25.0.0",
"@rollup/plugin-typescript": "^8.1.0", "@rollup/plugin-json": "^6.0.0",
"@rollup/plugin-terser": "^0.4.0",
"@rollup/plugin-typescript": "^11.1.0",
"@types/chai": "^4.2.14", "@types/chai": "^4.2.14",
"@types/fs-extra": "^9.0.6", "@types/fs-extra": "^9.0.6",
"@types/mocha": "^9.0.0", "@types/mocha": "^9.0.0",
@@ -81,7 +76,7 @@
"husky": "^4.3.7", "husky": "^4.3.7",
"lint-staged": "^10.5.3", "lint-staged": "^10.5.3",
"mocha": "^9.1.3", "mocha": "^9.1.3",
"node-fetch": "^2.6.7", "node-fetch": "^3.0.0",
"npm-run-all": "^4.1.5", "npm-run-all": "^4.1.5",
"onchange": "^7.1.0", "onchange": "^7.1.0",
"prettier": "^2.5.1", "prettier": "^2.5.1",
@@ -90,11 +85,11 @@
"puppeteer": "^13.0.0", "puppeteer": "^13.0.0",
"remark-emoji": "^2.1.0", "remark-emoji": "^2.1.0",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
"rollup": "^2.36.1", "rollup": "^3.0.0",
"rollup-plugin-terser": "^7.0.2",
"sinon": "^9.2.3", "sinon": "^9.2.3",
"ts-node": "^9.1.1", "ts-node": "^9.1.1",
"typescript": "^4.6.3" "typescript": "^4.8.4",
"wireit": "^0.7.2"
}, },
"eslintConfig": { "eslintConfig": {
"parser": "@typescript-eslint/parser", "parser": "@typescript-eslint/parser",
@@ -118,7 +113,8 @@
"@typescript-eslint/no-explicit-any": "off", "@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-empty-interface": "off", "@typescript-eslint/no-empty-interface": "off",
"@typescript-eslint/no-unused-vars": "error", "@typescript-eslint/no-unused-vars": "error",
"@typescript-eslint/no-var-requires": "off" "@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/ban-ts-comment": "off"
} }
}, },
"husky": { "husky": {

View File

@@ -1,12 +0,0 @@
// /**
// * @typedef {import('./src/types').BasicOptions} BasicOptions
// * @typedef {import('./src/types').SpaOptions} SpaOptions
// */
export { createBasicConfig, createBasicMetaConfig } from './src/createBasicConfig.js';
export { createSpaConfig, createSpaMetaConfig } from './src/createSpaConfig.js';
export { createMpaConfig, createMpaMetaConfig } from './src/createMpaConfig.js';
export {
createServiceWorkerConfig,
createServiceWorkerMetaConfig,
} from './src/createServiceWorkerConfig.js';

View File

@@ -13,10 +13,12 @@
}, },
"author": "Modern Web <hello@modern-web.dev> (https://modern-web.dev/)", "author": "Modern Web <hello@modern-web.dev> (https://modern-web.dev/)",
"homepage": "https://rocket.modern-web.dev/docs/tools/building-rollup/", "homepage": "https://rocket.modern-web.dev/docs/tools/building-rollup/",
"main": "./index.js",
"type": "module", "type": "module",
"exports": { "exports": {
".": "./index.js" ".": {
"types": "./dist-types/src/index.d.ts",
"default": "./src/index.js"
}
}, },
"scripts": { "scripts": {
"build:babelrc": "rimraf dist && rollup -c demo/babelrc/rollup.config.js", "build:babelrc": "rimraf dist && rollup -c demo/babelrc/rollup.config.js",
@@ -27,6 +29,7 @@
"build:spa-js-input": "rimraf dist && rollup -c demo/js/rollup.spa-js-input.config.js", "build:spa-js-input": "rimraf dist && rollup -c demo/js/rollup.spa-js-input.config.js",
"build:spa-nomodule": "rimraf dist && rollup -c demo/js/rollup.spa-nomodule.config.js", "build:spa-nomodule": "rimraf dist && rollup -c demo/js/rollup.spa-nomodule.config.js",
"build:ts": "rimraf dist && rollup -c demo/ts/rollup.spa.config.js", "build:ts": "rimraf dist && rollup -c demo/ts/rollup.spa.config.js",
"prepublishOnly": "npm run types",
"start:babelrc": "npm run build:babelrc && npm run start:build", "start:babelrc": "npm run build:babelrc && npm run start:build",
"start:build": "web-dev-server --root-dir dist --compatibility none --open", "start:build": "web-dev-server --root-dir dist --compatibility none --open",
"start:cjs": "npm run build:cjs && npm run start:build", "start:cjs": "npm run build:cjs && npm run start:build",
@@ -38,33 +41,52 @@
"start:ts": "npm run build:ts && npm run start:build", "start:ts": "npm run build:ts && npm run start:build",
"start:watch": "npm run build:spa-nomodule -- --watch & npm run start:build", "start:watch": "npm run build:spa-nomodule -- --watch & npm run start:build",
"test": "npm run test:node", "test": "npm run test:node",
"test:node": "mocha test-node/**/*.test.js --timeout 5000" "test:node": "mocha test-node/**/*.test.js --timeout 5000",
"types": "wireit"
}, },
"files": [ "files": [
"*.js", "dist-types",
"src" "src"
], ],
"keywords": [ "keywords": [
"rollup" "rollup"
], ],
"peerDependencies": { "peerDependencies": {
"rollup": "^2.35.0" "rollup": "^3.0.0"
}, },
"dependencies": { "dependencies": {
"@babel/core": "^7.12.10", "@babel/core": "^7.20.12",
"@babel/preset-env": "^7.12.11", "@babel/preset-env": "^7.12.11",
"@rollup/plugin-babel": "^5.2.2", "@rollup/plugin-babel": "^6.0.0",
"@rollup/plugin-node-resolve": "^11.0.1", "@rollup/plugin-node-resolve": "^15.0.1",
"@rollup/plugin-replace": "^2.4.2", "@rollup/plugin-replace": "^5.0.1",
"@web/rollup-plugin-html": "^1.8.0", "@rollup/plugin-terser": "^0.4.0",
"@web/rollup-plugin-import-meta-assets": "^1.0.4", "@web/rollup-plugin-html": "^2.0.0",
"@web/rollup-plugin-polyfills-loader": "^1.1.0", "@web/rollup-plugin-import-meta-assets": "^2.0.0",
"@web/rollup-plugin-polyfills-loader": "^2.0.0",
"browserslist": "^4.16.1", "browserslist": "^4.16.1",
"rollup-plugin-terser": "^7.0.2", "plugins-manager": "^0.3.1",
"workbox-broadcast-update": "^6.1.5", "workbox-broadcast-update": "^6.1.5",
"workbox-cacheable-response": "^6.1.5", "workbox-cacheable-response": "^6.1.5",
"workbox-expiration": "^6.1.5", "workbox-expiration": "^6.1.5",
"workbox-routing": "^6.1.5", "workbox-routing": "^6.1.5",
"workbox-strategies": "^6.1.5" "workbox-strategies": "^6.1.5"
},
"wireit": {
"types": {
"command": "copyfiles \"./types/**/*.d.ts\" dist-types/ && tsc --build --pretty",
"dependencies": [
"../plugins-manager:types"
],
"clean": "if-file-deleted",
"files": [
"src/**/*.js",
"tsconfig.json"
],
"output": [
"dist-types/**",
".tsbuildinfo"
]
}
} }
} }

View File

@@ -1,16 +1,22 @@
import resolve from '@rollup/plugin-node-resolve'; import resolve from '@rollup/plugin-node-resolve';
import { terser } from 'rollup-plugin-terser'; import terser from '@rollup/plugin-terser';
import babelPkg from '@rollup/plugin-babel'; import { babel } from '@rollup/plugin-babel';
import { applyPlugins } from 'plugins-manager'; import { applyPlugins } from 'plugins-manager';
const { babel } = babelPkg; /** @typedef {import('../types/main.js').BuildingRollupOptions} BuildingRollupOptions */
/**
* @param {BuildingRollupOptions} [userConfig]
*/
export function createBasicConfig(userConfig) { export function createBasicConfig(userConfig) {
const { config, metaPlugins } = createBasicMetaConfig(userConfig); const { config, metaPlugins } = createBasicMetaConfig(userConfig);
return applyPlugins(config, metaPlugins); return applyPlugins(config, metaPlugins);
} }
/**
* @param {BuildingRollupOptions} [userConfig]
*/
export function createBasicMetaConfig(userConfig = { output: {} }) { export function createBasicMetaConfig(userConfig = { output: {} }) {
const developmentMode = const developmentMode =
typeof userConfig.developmentMode !== 'undefined' typeof userConfig.developmentMode !== 'undefined'
@@ -37,8 +43,12 @@ export function createBasicMetaConfig(userConfig = { output: {} }) {
}, },
}; };
/**
* @type {import('plugins-manager').MetaPlugin<any>[]}
*/
let metaPlugins = [ let metaPlugins = [
{ {
// @ts-ignore
plugin: resolve, plugin: resolve,
options: { options: {
moduleDirectories: ['node_modules', 'web_modules'], moduleDirectories: ['node_modules', 'web_modules'],
@@ -71,7 +81,9 @@ export function createBasicMetaConfig(userConfig = { output: {} }) {
}, },
}, },
{ {
// @ts-ignore
plugin: terser, plugin: terser,
options: {},
}, },
]; ];

View File

@@ -1,7 +1,13 @@
import { createSpaMetaConfig } from './createSpaConfig.js'; import { createSpaMetaConfig } from './createSpaConfig.js';
import { adjustPluginOptions, applyPlugins } from 'plugins-manager'; import { adjustPluginOptions, applyPlugins } from 'plugins-manager';
// @ts-ignore
import { rollupPluginHTML } from '@web/rollup-plugin-html'; import { rollupPluginHTML } from '@web/rollup-plugin-html';
/** @typedef {import('../types/main.js').BuildingRollupOptions} BuildingRollupOptions */
/**
* @param {BuildingRollupOptions} [userConfig]
*/
export function createMpaConfig(userConfig) { export function createMpaConfig(userConfig) {
const { config, metaPlugins } = createMpaMetaConfig(userConfig); const { config, metaPlugins } = createMpaMetaConfig(userConfig);
@@ -9,6 +15,9 @@ export function createMpaConfig(userConfig) {
return final; return final;
} }
/**
* @param {BuildingRollupOptions} userConfig
*/
export function createMpaMetaConfig(userConfig = { output: {}, setupPlugins: [] }) { export function createMpaMetaConfig(userConfig = { output: {}, setupPlugins: [] }) {
const { config, metaPlugins } = createSpaMetaConfig(userConfig); const { config, metaPlugins } = createSpaMetaConfig(userConfig);

View File

@@ -1,17 +1,23 @@
import resolve from '@rollup/plugin-node-resolve'; import resolve from '@rollup/plugin-node-resolve';
import { terser } from 'rollup-plugin-terser'; import terser from '@rollup/plugin-terser';
import babelPkg from '@rollup/plugin-babel'; import { babel } from '@rollup/plugin-babel';
import replace from '@rollup/plugin-replace'; import replace from '@rollup/plugin-replace';
import { applyPlugins } from 'plugins-manager'; import { applyPlugins } from 'plugins-manager';
const { babel } = babelPkg; /** @typedef {import('../types/main.js').BuildingRollupOptions} BuildingRollupOptions */
/**
* @param {BuildingRollupOptions} userConfig
*/
export function createServiceWorkerConfig(userConfig) { export function createServiceWorkerConfig(userConfig) {
const { config, metaPlugins } = createServiceWorkerMetaConfig(userConfig); const { config, metaPlugins } = createServiceWorkerMetaConfig(userConfig);
return applyPlugins(config, metaPlugins); return applyPlugins(config, metaPlugins);
} }
/**
* @param {BuildingRollupOptions} userConfig
*/
export function createServiceWorkerMetaConfig(userConfig = { output: {} }) { export function createServiceWorkerMetaConfig(userConfig = { output: {} }) {
const developmentMode = const developmentMode =
typeof userConfig.developmentMode !== 'undefined' typeof userConfig.developmentMode !== 'undefined'
@@ -31,14 +37,19 @@ export function createServiceWorkerMetaConfig(userConfig = { output: {} }) {
}, },
}; };
/**
* @type {import('plugins-manager').MetaPlugin<any>[]}
*/
let metaPlugins = [ let metaPlugins = [
{ {
// @ts-ignore
plugin: resolve, plugin: resolve,
options: { options: {
moduleDirectories: ['node_modules', 'web_modules'], moduleDirectories: ['node_modules', 'web_modules'],
}, },
}, },
{ {
// @ts-ignore
plugin: replace, plugin: replace,
options: { options: {
'process.env.NODE_ENV': JSON.stringify(developmentMode ? 'development' : 'production'), 'process.env.NODE_ENV': JSON.stringify(developmentMode ? 'development' : 'production'),
@@ -72,6 +83,7 @@ export function createServiceWorkerMetaConfig(userConfig = { output: {} }) {
}, },
}, },
{ {
// @ts-ignore
plugin: terser, plugin: terser,
options: { options: {
mangle: { mangle: {

View File

@@ -1,15 +1,26 @@
// @ts-ignore
import { rollupPluginHTML } from '@web/rollup-plugin-html'; import { rollupPluginHTML } from '@web/rollup-plugin-html';
// @ts-ignore
import { importMetaAssets } from '@web/rollup-plugin-import-meta-assets'; import { importMetaAssets } from '@web/rollup-plugin-import-meta-assets';
// @ts-ignore
import { polyfillsLoader } from '@web/rollup-plugin-polyfills-loader'; import { polyfillsLoader } from '@web/rollup-plugin-polyfills-loader';
import { applyPlugins } from 'plugins-manager'; import { applyPlugins } from 'plugins-manager';
import { createBasicMetaConfig } from './createBasicConfig.js'; import { createBasicMetaConfig } from './createBasicConfig.js';
/** @typedef {import('../types/main.js').BuildingRollupOptions} BuildingRollupOptions */
/**
* @param {BuildingRollupOptions} [userConfig]
*/
export function createSpaConfig(userConfig) { export function createSpaConfig(userConfig) {
const { config, metaPlugins } = createSpaMetaConfig(userConfig); const { config, metaPlugins } = createSpaMetaConfig(userConfig);
return applyPlugins(config, metaPlugins); return applyPlugins(config, metaPlugins);
} }
/**
* @param {BuildingRollupOptions} userConfig
*/
export function createSpaMetaConfig(userConfig = { output: {} }) { export function createSpaMetaConfig(userConfig = { output: {} }) {
const { config, metaPlugins, developmentMode } = createBasicMetaConfig(userConfig); const { config, metaPlugins, developmentMode } = createBasicMetaConfig(userConfig);
@@ -27,8 +38,13 @@ export function createSpaMetaConfig(userConfig = { output: {} }) {
} }
delete config.absoluteBaseUrl; delete config.absoluteBaseUrl;
/**
* @type {import('plugins-manager').MetaPlugin<any>[]}
*/
const spaMetaPlugins = [ const spaMetaPlugins = [
// @ts-ignore
...metaPlugins, ...metaPlugins,
// @ts-ignore
{ {
plugin: rollupPluginHTML, plugin: rollupPluginHTML,
options: { options: {
@@ -36,9 +52,11 @@ export function createSpaMetaConfig(userConfig = { output: {} }) {
absoluteBaseUrl, absoluteBaseUrl,
}, },
}, },
// @ts-ignore
{ {
plugin: importMetaAssets, plugin: importMetaAssets,
}, },
// @ts-ignore
{ {
plugin: polyfillsLoader, plugin: polyfillsLoader,
options: { options: {

View File

@@ -0,0 +1,11 @@
/**
* @typedef {import('../types/main.js').BuildingRollupOptions} BuildingRollupOptions
*/
export { createBasicConfig, createBasicMetaConfig } from './createBasicConfig.js';
export { createSpaConfig, createSpaMetaConfig } from './createSpaConfig.js';
export { createMpaConfig, createMpaMetaConfig } from './createMpaConfig.js';
export {
createServiceWorkerConfig,
createServiceWorkerMetaConfig,
} from './createServiceWorkerConfig.js';

View File

@@ -1,6 +1,6 @@
import chai from 'chai'; import chai from 'chai';
import path from 'path'; import path from 'path';
import fs from 'fs'; import { readFile } from 'fs/promises';
import { fileURLToPath } from 'url'; import { fileURLToPath } from 'url';
import { rollup } from 'rollup'; import { rollup } from 'rollup';
@@ -8,7 +8,7 @@ const { expect } = chai;
const __dirname = path.dirname(fileURLToPath(import.meta.url)); const __dirname = path.dirname(fileURLToPath(import.meta.url));
/** /**
* @param {object} config * @param {import('@rocket/building-rollup').BuildingRollupOptions} config
*/ */
async function buildAndWrite(config) { async function buildAndWrite(config) {
const bundle = await rollup(config); const bundle = await rollup(config);
@@ -16,21 +16,27 @@ async function buildAndWrite(config) {
if (Array.isArray(config.output)) { if (Array.isArray(config.output)) {
await bundle.write(config.output[0]); await bundle.write(config.output[0]);
await bundle.write(config.output[1]); await bundle.write(config.output[1]);
} else { } else if (config.output) {
await bundle.write(config.output); await bundle.write(config.output);
} }
} }
/**
* @param {string} configString
* @returns
*/
async function execute(configString) { async function execute(configString) {
const configPath = path.join(__dirname, 'fixtures', configString.split('/').join(path.sep)); const configPath = path.join(__dirname, 'fixtures', configString.split('/').join(path.sep));
const config = (await import(configPath)).default; const config = (await import(configPath)).default;
await buildAndWrite(config); await buildAndWrite(config);
/**
* @param {string} fileName
*/
return async (fileName, { stripToBody = false, stripStartEndWhitespace = true } = {}) => { return async (fileName, { stripToBody = false, stripStartEndWhitespace = true } = {}) => {
let text = await fs.promises.readFile( let text = (
path.join(config.output.dir, fileName.split('/').join(path.sep)), await readFile(path.join(config.output.dir, fileName.split('/').join(path.sep)))
); ).toString();
text = text.toString();
if (stripToBody) { if (stripToBody) {
const bodyOpenTagEnd = text.indexOf('>', text.indexOf('<body') + 1) + 1; const bodyOpenTagEnd = text.indexOf('>', text.indexOf('<body') + 1) + 1;
const bodyCloseTagStart = text.indexOf('</body>'); const bodyCloseTagStart = text.indexOf('</body>');

View File

@@ -1,10 +1,11 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */
import puppeteer from 'puppeteer'; import puppeteer from 'puppeteer';
import chai from 'chai'; import chai from 'chai';
import path from 'path'; import path from 'path';
import fs from 'fs'; import fs from 'fs';
// @ts-ignore
import rimraf from 'rimraf'; import rimraf from 'rimraf';
import { rollup } from 'rollup'; import { rollup } from 'rollup';
// @ts-ignore
import { startDevServer } from '@web/dev-server'; import { startDevServer } from '@web/dev-server';
import { fileURLToPath } from 'url'; import { fileURLToPath } from 'url';
@@ -14,6 +15,7 @@ const rootDir = path.resolve(__dirname, '..', 'dist');
const { expect } = chai; const { expect } = chai;
describe('spa integration tests', () => { describe('spa integration tests', () => {
// @ts-ignore
let server; let server;
/** @type {import('puppeteer').Browser} */ /** @type {import('puppeteer').Browser} */
let browser; let browser;
@@ -27,6 +29,7 @@ describe('spa integration tests', () => {
readCliArgs: false, readCliArgs: false,
readFileConfig: false, readFileConfig: false,
logStartMessage: false, logStartMessage: false,
// @ts-ignore
clearTerminalOnReload: false, clearTerminalOnReload: false,
}); });
browser = await puppeteer.launch(); browser = await puppeteer.launch();
@@ -35,6 +38,7 @@ describe('spa integration tests', () => {
after(async () => { after(async () => {
await browser.close(); await browser.close();
// @ts-ignore
await server.stop(); await server.stop();
}); });
@@ -45,6 +49,7 @@ describe('spa integration tests', () => {
].forEach(testCase => { ].forEach(testCase => {
describe(`testcase ${testCase}`, function describe() { describe(`testcase ${testCase}`, function describe() {
this.timeout(30000); this.timeout(30000);
// @ts-ignore
let page; let page;
before(async () => { before(async () => {

View File

@@ -0,0 +1,15 @@
{
"extends": "../../tsconfig.node-base.json",
"compilerOptions": {
"module": "ESNext",
"outDir": "./dist-types",
"rootDir": ".",
"composite": true,
"allowJs": true,
"checkJs": true,
"emitDeclarationOnly": true,
"moduleResolution": "NodeNext"
},
"include": ["src", "types", "test-node"],
"exclude": ["dist-types"]
}

View File

@@ -0,0 +1,8 @@
import { RollupOptions } from 'rollup';
interface BuildingRollupOptions extends RollupOptions {
developmentMode?: boolean;
rootDir?: string;
absoluteBaseUrl?: string;
setupPlugins?: function[];
}

View File

@@ -1,5 +1,21 @@
# check-html-links # check-html-links
## 0.2.4
### Patch Changes
- 97d5fb2: Add external links validation via the flag `--validate-externals`.
You can/should provide an optional `--absolute-base-url` to handle urls starting with it as internal.
```bash
# check external urls
npx check-html-links _site --validate-externals
# check external urls but treat links like https://rocket.modern-web.dev/about/ as internal
npx check-html-links _site --validate-externals --absolute-base-url https://rocket.modern-web.dev
```
## 0.2.3 ## 0.2.3
### Patch Changes ### Patch Changes

View File

@@ -14,7 +14,7 @@ npm i -D check-html-links
npx check-html-links _site npx check-html-links _site
``` ```
For docs please see our homepage [https://rocket.modern-web.dev/docs/tools/check-html-links/](https://rocket.modern-web.dev/docs/tools/check-html-links/). For docs please see our homepage [https://rocket.modern-web.dev/tools/check-html-links/overview/](https://rocket.modern-web.dev/tools/check-html-links/overview/).
## Comparison ## Comparison

View File

@@ -1,6 +1,6 @@
{ {
"name": "check-html-links", "name": "check-html-links",
"version": "0.2.3", "version": "0.2.4",
"publishConfig": { "publishConfig": {
"access": "public" "access": "public"
}, },
@@ -37,6 +37,7 @@
"command-line-args": "^5.1.1", "command-line-args": "^5.1.1",
"glob": "^7.0.0", "glob": "^7.0.0",
"minimatch": "^3.0.4", "minimatch": "^3.0.4",
"node-fetch": "^3.0.0",
"sax-wasm": "^2.0.0", "sax-wasm": "^2.0.0",
"slash": "^4.0.0" "slash": "^4.0.0"
}, },

View File

@@ -1,12 +1,10 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */
/** @typedef {import('../types/main').CheckHtmlLinksCliOptions} CheckHtmlLinksCliOptions */ /** @typedef {import('../types/main').CheckHtmlLinksCliOptions} CheckHtmlLinksCliOptions */
import path from 'path'; import path from 'path';
import chalk from 'chalk'; import chalk from 'chalk';
import commandLineArgs from 'command-line-args'; import commandLineArgs from 'command-line-args';
import { validateFiles } from './validateFolder.js'; import { prepareFiles, validateFiles } from './validateFolder.js';
import { formatErrors } from './formatErrors.js'; import { formatErrors } from './formatErrors.js';
import { listFiles } from './listFiles.js'; import { listFiles } from './listFiles.js';
@@ -18,7 +16,9 @@ export class CheckHtmlLinksCli {
const mainDefinitions = [ const mainDefinitions = [
{ name: 'ignore-link-pattern', type: String, multiple: true }, { name: 'ignore-link-pattern', type: String, multiple: true },
{ name: 'root-dir', type: String, defaultOption: true }, { name: 'root-dir', type: String, defaultOption: true },
{ name: 'continue-on-error', type: Boolean, defaultOption: false }, { name: 'continue-on-error', type: Boolean },
{ name: 'validate-externals', type: Boolean },
{ name: 'absolute-base-url', type: String },
]; ];
const options = commandLineArgs(mainDefinitions, { const options = commandLineArgs(mainDefinitions, {
stopAtFirstUnknown: true, stopAtFirstUnknown: true,
@@ -29,6 +29,8 @@ export class CheckHtmlLinksCli {
continueOnError: options['continue-on-error'], continueOnError: options['continue-on-error'],
rootDir: options['root-dir'], rootDir: options['root-dir'],
ignoreLinkPatterns: options['ignore-link-pattern'], ignoreLinkPatterns: options['ignore-link-pattern'],
validateExternals: options['validate-externals'],
absoluteBaseUrl: options['absolute-base-url'],
}; };
} }
@@ -43,22 +45,47 @@ export class CheckHtmlLinksCli {
} }
async run() { async run() {
const { ignoreLinkPatterns, rootDir: userRootDir } = this.options; const {
ignoreLinkPatterns,
rootDir: userRootDir,
validateExternals,
absoluteBaseUrl,
} = this.options;
const rootDir = userRootDir ? path.resolve(userRootDir) : process.cwd(); const rootDir = userRootDir ? path.resolve(userRootDir) : process.cwd();
const performanceStart = process.hrtime(); const performanceStart = process.hrtime();
console.log('👀 Checking if all internal links work...');
const files = await listFiles('**/*.html', rootDir); const files = await listFiles('**/*.html', rootDir);
console.log('Check HTML Links');
const filesOutput = const filesOutput =
files.length == 0 files.length == 0
? '🧐 No files to check. Did you select the correct folder?' ? ' 🧐 No files to check. Did you select the correct folder?'
: `🔥 Found a total of ${chalk.green.bold(files.length)} files to check!`; : ` 📖 Found ${chalk.green.bold(files.length)} files containing`;
console.log(filesOutput); console.log(filesOutput);
const { errors, numberLinks } = await validateFiles(files, rootDir, { ignoreLinkPatterns }); const { numberLinks, checkLocalFiles, checkExternalLinks } = await prepareFiles(
files,
rootDir,
{
ignoreLinkPatterns,
validateExternals,
absoluteBaseUrl,
},
);
console.log(`🔗 Found a total of ${chalk.green.bold(numberLinks)} links to validate!\n`); console.log(` 🔗 ${chalk.green.bold(numberLinks)} internal links`);
if (validateExternals) {
console.log(` 🌐 ${chalk.green.bold(checkExternalLinks.length)} external links`);
}
console.log(' 👀 Checking...');
const { errors } = await validateFiles({
checkLocalFiles,
validateExternals,
checkExternalLinks,
});
const performance = process.hrtime(performanceStart); const performance = process.hrtime(performanceStart);
/** @type {string[]} */ /** @type {string[]} */
@@ -70,7 +97,7 @@ export class CheckHtmlLinksCli {
referenceCount += error.usage.length; referenceCount += error.usage.length;
} }
output = [ output = [
`❌ Found ${chalk.red.bold( ` ❌ Found ${chalk.red.bold(
errors.length.toString(), errors.length.toString(),
)} missing reference targets (used by ${referenceCount} links) while checking ${ )} missing reference targets (used by ${referenceCount} links) while checking ${
files.length files.length
@@ -78,7 +105,7 @@ export class CheckHtmlLinksCli {
...formatErrors(errors) ...formatErrors(errors)
.split('\n') .split('\n')
.map(line => ` ${line}`), .map(line => ` ${line}`),
`Checking links duration: ${performance[0]}s ${performance[1] / 1000000}ms`, ` 🕑 Checking links duration: ${performance[0]}s ${performance[1] / 1000000}ms`,
]; ];
message = output.join('\n'); message = output.join('\n');
if (this.options.printOnError === true) { if (this.options.printOnError === true) {
@@ -89,7 +116,7 @@ export class CheckHtmlLinksCli {
} }
} else { } else {
console.log( console.log(
`✅ All internal links are valid. (executed in ${performance[0]}s ${ ` ✅ All tested links are valid. (executed in ${performance[0]}s ${
performance[1] / 1000000 performance[1] / 1000000
}ms)`, }ms)`,
); );

View File

@@ -0,0 +1,63 @@
import fetch from 'node-fetch';
/**
* @type {Map<string,boolean>}
*/
const resultsMap = new Map();
/**
*
* @param {string} url
* @param {boolean} result
* @returns {boolean}
*/
const memorizeCheckup = (url, result) => {
resultsMap.set(url, result);
return result;
};
/**
*
* @param {string} url
* @param {string} method
* @returns
*/
const fetchWrap = async (url, method = 'GET') => {
return Promise.race([
fetch(url, { method })
.then(response => response.ok)
.catch(() => false),
new Promise(resolve => setTimeout(resolve, 10000, false)),
]);
};
/**
*
* @param {string} url
* @returns {Promise<boolean>}
*/
const fetchHead = async url => fetchWrap(url, 'HEAD');
/**
*
* @param {string} url - URL object to check
* @returns {Promise<boolean>} true if url is alive or false if not
*/
const checkUrl = async url =>
(fetchHead(url) || fetchWrap(url)).then(result => memorizeCheckup(url, result));
/**
*
* @param {string} link - link string to check
* @returns {Promise<boolean>}
*/
export const checkLink = async link => {
const url = link.startsWith('//') ? `https:${link}` : link;
return resultsMap.get(url) ?? checkUrl(url);
};
/**
* Check an array of links and return an object with
*
* @param {string[]} links Links to check
*/
export const checkLinks = async links => Promise.all(links.map(checkLink));

View File

@@ -15,7 +15,7 @@ export function formatErrors(errors, relativeFrom = process.cwd()) {
const filePath = path.relative(relativeFrom, error.filePath); const filePath = path.relative(relativeFrom, error.filePath);
if (error.onlyAnchorMissing === true) { if (error.onlyAnchorMissing === true) {
output.push( output.push(
`${number}. missing ${chalk.red.bold( ` ${number}. missing ${chalk.red.bold(
`id="${error.usage[0].anchor}"`, `id="${error.usage[0].anchor}"`,
)} in ${chalk.cyanBright(filePath)}`, )} in ${chalk.cyanBright(filePath)}`,
); );
@@ -24,7 +24,7 @@ export function formatErrors(errors, relativeFrom = process.cwd()) {
const title = const title =
firstAttribute === 'src' || firstAttribute === 'srcset' ? 'file' : 'reference target'; firstAttribute === 'src' || firstAttribute === 'srcset' ? 'file' : 'reference target';
output.push(`${number}. missing ${title} ${chalk.red.bold(filePath)}`); output.push(` ${number}. missing ${title} ${chalk.red.bold(filePath)}`);
} }
const usageLength = error.usage.length; const usageLength = error.usage.length;
@@ -34,11 +34,11 @@ export function formatErrors(errors, relativeFrom = process.cwd()) {
const clickAbleLink = chalk.cyanBright(`${usagePath}:${usage.line + 1}:${usage.character}`); const clickAbleLink = chalk.cyanBright(`${usagePath}:${usage.line + 1}:${usage.character}`);
const attributeStart = chalk.gray(`${usage.attribute}="`); const attributeStart = chalk.gray(`${usage.attribute}="`);
const attributeEnd = chalk.gray('"'); const attributeEnd = chalk.gray('"');
output.push(` from ${clickAbleLink} via ${attributeStart}${usage.value}${attributeEnd}`); output.push(` from ${clickAbleLink} via ${attributeStart}${usage.value}${attributeEnd}`);
} }
if (usageLength > 3) { if (usageLength > 3) {
const more = chalk.red((usageLength - 3).toString()); const more = chalk.red((usageLength - 3).toString());
output.push(` ... ${more} more references to this target`); output.push(` ... ${more} more references to this target`);
} }
output.push(''); output.push('');
} }

View File

@@ -1,12 +1,11 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */
import fs from 'fs'; import fs from 'fs';
import saxWasm from 'sax-wasm'; import saxWasm from 'sax-wasm';
import minimatch from 'minimatch'; import minimatch from 'minimatch';
import { createRequire } from 'module'; import { createRequire } from 'module';
import { listFiles } from './listFiles.js';
import path from 'path'; import path from 'path';
import slash from 'slash'; import slash from 'slash';
import { listFiles } from './listFiles.js';
import { checkLinks } from './checkLinks.js';
/** @typedef {import('../types/main').Link} Link */ /** @typedef {import('../types/main').Link} Link */
/** @typedef {import('../types/main').LocalFile} LocalFile */ /** @typedef {import('../types/main').LocalFile} LocalFile */
@@ -28,6 +27,9 @@ const parserIds = new SAXParser(SaxEventType.Attribute, streamOptions);
/** @type {Error[]} */ /** @type {Error[]} */
let checkLocalFiles = []; let checkLocalFiles = [];
/** @type {Error[]} */
let checkExternalLinks = [];
/** @type {Error[]} */ /** @type {Error[]} */
let errors = []; let errors = [];
@@ -151,6 +153,26 @@ function addLocalFile(filePath, anchor, usageObj) {
} }
} }
/**
* @param {string} filePath
* @param {Usage} usageObj
*/
function addExternalLink(filePath, usageObj) {
const foundIndex = checkExternalLinks.findIndex(item => {
return item.filePath === filePath;
});
if (foundIndex === -1) {
checkExternalLinks.push({
filePath,
onlyAnchorMissing: false,
usage: [usageObj],
});
} else {
checkExternalLinks[foundIndex].usage.push(usageObj);
}
}
/** /**
* @param {string} inValue * @param {string} inValue
*/ */
@@ -200,11 +222,16 @@ function isNonHttpSchema(url) {
* @param {object} options * @param {object} options
* @param {string} options.htmlFilePath * @param {string} options.htmlFilePath
* @param {string} options.rootDir * @param {string} options.rootDir
* @param {string} options.absoluteBaseUrl
* @param {function(string): boolean} options.ignoreUsage * @param {function(string): boolean} options.ignoreUsage
*/ */
async function resolveLinks(links, { htmlFilePath, rootDir, ignoreUsage }) { async function resolveLinks(links, { htmlFilePath, rootDir, ignoreUsage, absoluteBaseUrl }) {
for (const hrefObj of links) { for (const hrefObj of links) {
const { value, anchor } = getValueAndAnchor(hrefObj.value); const { value: rawValue, anchor } = getValueAndAnchor(hrefObj.value);
const value = rawValue.startsWith(absoluteBaseUrl)
? rawValue.substring(absoluteBaseUrl.length)
: rawValue;
const usageObj = { const usageObj = {
attribute: hrefObj.attribute, attribute: hrefObj.attribute,
@@ -229,8 +256,7 @@ async function resolveLinks(links, { htmlFilePath, rootDir, ignoreUsage }) {
} else if (valueFile === '' && anchor !== '') { } else if (valueFile === '' && anchor !== '') {
addLocalFile(htmlFilePath, anchor, usageObj); addLocalFile(htmlFilePath, anchor, usageObj);
} else if (value.startsWith('//') || value.startsWith('http')) { } else if (value.startsWith('//') || value.startsWith('http')) {
// TODO: handle external urls addExternalLink(htmlFilePath, usageObj);
// external url - we do not handle that (yet)
} else if (value.startsWith('/')) { } else if (value.startsWith('/')) {
const filePath = path.join(rootDir, valueFile); const filePath = path.join(rootDir, valueFile);
addLocalFile(filePath, anchor, usageObj); addLocalFile(filePath, anchor, usageObj);
@@ -244,7 +270,7 @@ async function resolveLinks(links, { htmlFilePath, rootDir, ignoreUsage }) {
} }
} }
return { checkLocalFiles: [...checkLocalFiles] }; return { checkLocalFiles: [...checkLocalFiles], checkExternalLinks: [...checkExternalLinks] };
} }
/** /**
@@ -283,17 +309,34 @@ async function validateLocalFiles(checkLocalFiles) {
return errors; return errors;
} }
/**
*
* @param {Error[]} checkExternalLinks
*/
async function validateExternalLinks(checkExternalLinks) {
for await (const localFileObj of checkExternalLinks) {
const links = localFileObj.usage.map(usage => usage.value);
const results = await checkLinks(links);
localFileObj.usage = localFileObj.usage.filter((link, index) => !results[index]);
if (localFileObj.usage.length > 0) {
errors.push(localFileObj);
}
}
return errors;
}
/** /**
* @param {string[]} files * @param {string[]} files
* @param {string} rootDir * @param {string} rootDir
* @param {Options} opts? * @param {Options} opts?
*/ */
export async function validateFiles(files, rootDir, opts) { export async function prepareFiles(files, rootDir, opts) {
await parserReferences.prepareWasm(saxWasmBuffer); await parserReferences.prepareWasm(saxWasmBuffer);
await parserIds.prepareWasm(saxWasmBuffer); await parserIds.prepareWasm(saxWasmBuffer);
errors = []; errors = [];
checkLocalFiles = []; checkLocalFiles = [];
checkExternalLinks = [];
idCache = new Map(); idCache = new Map();
let numberLinks = 0; let numberLinks = 0;
@@ -309,11 +352,27 @@ export async function validateFiles(files, rootDir, opts) {
for (const htmlFilePath of files) { for (const htmlFilePath of files) {
const { links } = await extractReferences(htmlFilePath); const { links } = await extractReferences(htmlFilePath);
numberLinks += links.length; numberLinks += links.length;
await resolveLinks(links, { htmlFilePath, rootDir, ignoreUsage }); await resolveLinks(links, {
htmlFilePath,
rootDir,
ignoreUsage,
absoluteBaseUrl: opts?.absoluteBaseUrl,
});
} }
await validateLocalFiles(checkLocalFiles); return { checkLocalFiles, checkExternalLinks, numberLinks };
}
return { errors: errors, numberLinks: numberLinks }; /**
* @param {*} param0
* @returns
*/
export async function validateFiles({ checkLocalFiles, validateExternals, checkExternalLinks }) {
await validateLocalFiles(checkLocalFiles);
if (validateExternals) {
await validateExternalLinks(checkExternalLinks);
}
return { errors };
} }
/** /**
@@ -323,6 +382,14 @@ export async function validateFiles(files, rootDir, opts) {
export async function validateFolder(inRootDir, opts) { export async function validateFolder(inRootDir, opts) {
const rootDir = path.resolve(inRootDir); const rootDir = path.resolve(inRootDir);
const files = await listFiles('**/*.html', rootDir); const files = await listFiles('**/*.html', rootDir);
const { errors } = await validateFiles(files, rootDir, opts);
const { checkLocalFiles, checkExternalLinks } = await prepareFiles(files, rootDir, opts);
const { errors } = await validateFiles({
checkLocalFiles,
validateExternals: opts?.validateExternals,
checkExternalLinks,
});
return errors; return errors;
} }

View File

@@ -1,5 +1,9 @@
<!-- ignore known subsystems --> <!-- valid -->
<a href="/docs/"></a> <a href="//rocket.modern-web.dev/"></a>
<a href="/developer/getting-started.html#js"></a> <a href="http://rocket.modern-web.dev/"></a>
<a href="/developer/language-guides/"></a> <a href="https://rocket.modern-web.dev/"></a>
<a href="/developer/javascript.html"></a>
<!-- invalid -->
<a href="//rocket.modern-web.dev/unexists-page/"></a>
<a href="http://rocket.modern-web.dev/unexists-page/"></a>
<a href="https://rocket.modern-web.dev/unexists-page/"></a>

View File

@@ -5,8 +5,5 @@
<a href="./page.html"></a> <a href="./page.html"></a>
<a href=" ./page.html "></a> <a href=" ./page.html "></a>
<a href=" /page.html "></a> <a href=" /page.html "></a>
<a href="//domain.com/something/"></a>
<a href="http://domain.com/something/"></a>
<a href="https://domain.com/something/"></a>
<a href=""></a> <a href=""></a>
<a href=":~:text=put%20your%20labels%20above%20your%20inputs">Sign-in form best practices</a> <a href=":~:text=put%20your%20labels%20above%20your%20inputs">Sign-in form best practices</a>

View File

@@ -0,0 +1,2 @@
<a href="about.html">About</a>
<a href="http://localhost/about.html">About Absolute</a>

View File

@@ -20,19 +20,19 @@ describe('formatErrors', () => {
const result = await executeAndFormat('fixtures/test-case'); const result = await executeAndFormat('fixtures/test-case');
expect(result.trim().split('\n')).to.deep.equal([ expect(result.trim().split('\n')).to.deep.equal([
'1. missing id="my-teams" in fixtures/test-case/price/index.html', '1. missing id="my-teams" in fixtures/test-case/price/index.html',
' from fixtures/test-case/history/index.html:1:9 via href="/price/#my-teams"', ' from fixtures/test-case/history/index.html:1:9 via href="/price/#my-teams"',
'', '',
'2. missing file fixtures/test-case/about/images/team.png', ' 2. missing file fixtures/test-case/about/images/team.png',
' from fixtures/test-case/about/index.html:3:10 via src="./images/team.png"', ' from fixtures/test-case/about/index.html:3:10 via src="./images/team.png"',
'', '',
'3. missing reference target fixtures/test-case/aboot', ' 3. missing reference target fixtures/test-case/aboot',
' from fixtures/test-case/about/index.html:6:11 via href="/aboot"', ' from fixtures/test-case/about/index.html:6:11 via href="/aboot"',
' from fixtures/test-case/history/index.html:4:11 via href="/aboot"', ' from fixtures/test-case/history/index.html:4:11 via href="/aboot"',
' from fixtures/test-case/index.html:4:11 via href="/aboot"', ' from fixtures/test-case/index.html:4:11 via href="/aboot"',
' ... 2 more references to this target', ' ... 2 more references to this target',
'', '',
'4. missing reference target fixtures/test-case/prce', ' 4. missing reference target fixtures/test-case/prce',
' from fixtures/test-case/index.html:1:9 via href="./prce"', ' from fixtures/test-case/index.html:1:9 via href="./prce"',
]); ]);
}); });
}); });

View File

@@ -66,6 +66,74 @@ describe('validateFolder', () => {
]); ]);
}); });
it('validates external links', async () => {
const { errors, cleanup } = await execute('fixtures/external-link', {
validateExternals: true,
});
expect(cleanup(errors)).to.deep.equal([
{
filePath: 'fixtures/external-link/index.html',
onlyAnchorMissing: false,
usage: [
{
attribute: 'href',
value: '//rocket.modern-web.dev/unexists-page/',
file: 'fixtures/external-link/index.html',
line: 6,
character: 9,
anchor: '',
},
{
attribute: 'href',
value: 'http://rocket.modern-web.dev/unexists-page/',
file: 'fixtures/external-link/index.html',
line: 7,
character: 9,
anchor: '',
},
{
attribute: 'href',
value: 'https://rocket.modern-web.dev/unexists-page/',
file: 'fixtures/external-link/index.html',
line: 8,
character: 9,
anchor: '',
},
],
},
]);
});
it('validates links with own absolute base url as internal', async () => {
const { errors, cleanup } = await execute('fixtures/internal-own-absolute-base-path', {
validateExternals: true,
absoluteBaseUrl: 'http://localhost',
});
expect(cleanup(errors)).to.deep.equal([]);
});
it('validates all full urls if there is no absoluteBaseUrl provided', async () => {
const { errors, cleanup } = await execute('fixtures/internal-own-absolute-base-path', {
validateExternals: true,
});
expect(cleanup(errors)).to.deep.equal([
{
filePath: 'fixtures/internal-own-absolute-base-path/index.html',
onlyAnchorMissing: false,
usage: [
{
anchor: '',
attribute: 'href',
character: 9,
file: 'fixtures/internal-own-absolute-base-path/index.html',
line: 1,
value: 'http://localhost/about.html',
},
],
},
]);
});
it('groups multiple usage of the same missing file', async () => { it('groups multiple usage of the same missing file', async () => {
const { errors, cleanup } = await execute('fixtures/internal-links-to-same-file'); const { errors, cleanup } = await execute('fixtures/internal-links-to-same-file');
expect(cleanup(errors)).to.deep.equal([ expect(cleanup(errors)).to.deep.equal([

View File

@@ -26,13 +26,15 @@ export interface Error {
usage: Usage[]; usage: Usage[];
} }
interface Options { export interface Options {
ignoreLinkPatterns: string[] | null; ignoreLinkPatterns: string[] | null;
validateExternals: boolean;
absoluteBaseUrl: string;
} }
export interface CheckHtmlLinksCliOptions { export interface CheckHtmlLinksCliOptions extends Options {
printOnError: boolean; printOnError: boolean;
rootDir: string; rootDir: string;
ignoreLinkPatterns: string[] | null;
continueOnError: boolean; continueOnError: boolean;
absoluteBaseUrl: string;
} }

View File

@@ -1,5 +1,20 @@
# @rocket/cli # @rocket/cli
## 0.20.4
### Patch Changes
- 68e05f4: `rocket lint` can now validate external links.
Example:
```
rocket lint --validate-externals
```
- Updated dependencies [97d5fb2]
- check-html-links@0.2.4
## 0.20.3 ## 0.20.3
### Patch Changes ### Patch Changes

View File

@@ -1,6 +1,6 @@
{ {
"name": "@rocket/cli", "name": "@rocket/cli",
"version": "0.20.3", "version": "0.20.4",
"publishConfig": { "publishConfig": {
"access": "public" "access": "public"
}, },
@@ -13,7 +13,6 @@
}, },
"author": "Modern Web <hello@modern-web.dev> (https://modern-web.dev/)", "author": "Modern Web <hello@modern-web.dev> (https://modern-web.dev/)",
"homepage": "https://rocket.modern-web.dev/", "homepage": "https://rocket.modern-web.dev/",
"main": "./src/index.js",
"bin": { "bin": {
"rocket": "src/cli.js" "rocket": "src/cli.js"
}, },
@@ -30,12 +29,13 @@
}, },
"scripts": { "scripts": {
"build": "npm run rocket:build", "build": "npm run rocket:build",
"prepublishOnly": "npm run types",
"rocket:build": "node src/cli.js build -c demo", "rocket:build": "node src/cli.js build -c demo",
"rocket:start": "node src/cli.js start -c demo", "rocket:start": "node src/cli.js start -c demo",
"start": "npm run rocket:start", "start": "npm run rocket:start",
"test": "mocha --require ../../scripts/testMochaGlobalHooks.js test-node/**/*.test.{js,cjs} test-node/*.test.{js,cjs} --timeout 8000", "test": "mocha --require ../../scripts/testMochaGlobalHooks.js test-node/**/*.test.{js,cjs} test-node/*.test.{js,cjs} --timeout 8000",
"test:watch": "onchange 'src/**/*.{js,cjs}' 'test-node/**/*.{js,cjs}' -- npm test", "test:watch": "onchange 'src/**/*.{js,cjs}' 'test-node/**/*.{js,cjs}' -- npm test",
"types:copy": "copyfiles \"./types/**/*.d.ts\" dist-types/", "types": "wireit",
"xtest:watch": "mocha test/**/*.test.js --parallel --watch" "xtest:watch": "mocha test/**/*.test.js --parallel --watch"
}, },
"files": [ "files": [
@@ -52,9 +52,9 @@
"rollup" "rollup"
], ],
"dependencies": { "dependencies": {
"@rocket/building-rollup": "^0.4.0", "@rocket/building-rollup": "^0.4.1",
"@rocket/engine": "^0.2.7", "@rocket/engine": "^0.2.7",
"check-html-links": "^0.2.3", "check-html-links": "^0.2.4",
"colorette": "^2.0.16", "colorette": "^2.0.16",
"commander": "^9.0.0", "commander": "^9.0.0",
"fs-extra": "^9.0.1", "fs-extra": "^9.0.1",
@@ -67,14 +67,22 @@
"@types/ip": "^1.1.0", "@types/ip": "^1.1.0",
"koa-proxy": "^1.0.0-alpha.3" "koa-proxy": "^1.0.0-alpha.3"
}, },
"types": "./dist-types/src/index.d.ts", "wireit": {
"typesVersions": { "types": {
"*": { "command": "copyfiles \"./types/**/*.d.ts\" dist-types/ && tsc --build --pretty",
"*": [ "dependencies": [
"./dist-types/src/index.d.ts" "../plugins-manager:types",
"../engine:types",
"../building-rollup:types"
], ],
"test-helpers": [ "clean": "if-file-deleted",
"./dist-types/test-helpers/index.d.ts" "files": [
"src/**/*.js",
"tsconfig.json"
],
"output": [
"dist-types/**",
".tsbuildinfo"
] ]
} }
} }

View File

@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */
import path from 'path'; import path from 'path';
import { existsSync } from 'fs'; import { existsSync } from 'fs';

View File

@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */
import { Command } from 'commander'; import { Command } from 'commander';
import { RocketStart } from './RocketStart.js'; import { RocketStart } from './RocketStart.js';
import { RocketBuild } from './RocketBuild.js'; import { RocketBuild } from './RocketBuild.js';

View File

@@ -1,5 +1,3 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */
// @ts-ignore // @ts-ignore
import { CheckHtmlLinksCli } from 'check-html-links'; import { CheckHtmlLinksCli } from 'check-html-links';
import { bold, gray } from 'colorette'; import { bold, gray } from 'colorette';
@@ -24,6 +22,7 @@ export class RocketLint {
.command('lint') .command('lint')
.option('-i, --input-dir <path>', 'path to where to search for source files') .option('-i, --input-dir <path>', 'path to where to search for source files')
.option('-b, --build-html', 'do a quick html only build and then check links') .option('-b, --build-html', 'do a quick html only build and then check links')
.option('-e, --validate-externals', 'validate external links')
.action(async options => { .action(async options => {
const { cliOptions, ...lintOptions } = options; const { cliOptions, ...lintOptions } = options;
cli.setOptions({ cli.setOptions({
@@ -77,6 +76,7 @@ export class RocketLint {
rootDir: folderToCheck, rootDir: folderToCheck,
printOnError: true, printOnError: true,
continueOnError: false, continueOnError: false,
absoluteBaseUrl: this.cli.options.absoluteBaseUrl,
...userCheckHtmlLinksOptions, ...userCheckHtmlLinksOptions,
}); });

View File

@@ -1,9 +1,7 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */
import path from 'path'; import path from 'path';
import { existsSync } from 'fs'; import { existsSync } from 'fs';
import { rollup } from 'rollup'; import { rollup } from 'rollup';
// @ts-ignore
import { createMpaConfig, createServiceWorkerConfig } from '@rocket/building-rollup'; import { createMpaConfig, createServiceWorkerConfig } from '@rocket/building-rollup';
// import { rollupPluginHTML } from '@web/rollup-plugin-html'; // import { rollupPluginHTML } from '@web/rollup-plugin-html';

View File

@@ -1,7 +1,5 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */
// @ts-nocheck // @ts-nocheck
/* eslint-disable @typescript-eslint/ban-ts-comment */
const fs = require('fs'); const fs = require('fs');
const path = require('path'); const path = require('path');
const EleventyImage = require('@11ty/eleventy-img'); const EleventyImage = require('@11ty/eleventy-img');

View File

@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */
// @ts-nocheck // @ts-nocheck
/** /**

View File

@@ -74,7 +74,7 @@ describe('Config', () => {
testOptions: { captureLogs: true }, testOptions: { captureLogs: true },
}); });
await build(); await build();
const inlineModule = await readOutput('e97af63d.js', { format: false }); const inlineModule = await readOutput('ddcef8d1.js', { format: false });
expect(inlineModule).to.equal('var a={test:"data"};console.log(a);\n'); expect(inlineModule).to.equal('var a={test:"data"};console.log(a);\n');
}); });

View File

@@ -1,5 +1,3 @@
// Don't edit this file directly. It is generated by /scripts/update-package-configs.ts
{ {
"extends": "../../tsconfig.node-base.json", "extends": "../../tsconfig.node-base.json",
"compilerOptions": { "compilerOptions": {
@@ -9,27 +7,9 @@
"composite": true, "composite": true,
"allowJs": true, "allowJs": true,
"checkJs": true, "checkJs": true,
"emitDeclarationOnly": true "emitDeclarationOnly": true,
"moduleResolution": "NodeNext"
}, },
"references": [ "include": ["src", "types"],
{ "exclude": ["dist-types", "**/__output/**", "**/__output-dev/**"]
"path": "../plugins-manager/tsconfig.json" }
},
{
"path": "../mdjs-core/tsconfig.json"
},
{
"path": "../engine/tsconfig.json"
}
],
"include": [
"src",
"*.js",
"types"
],
"exclude": [
"dist",
"dist-types",
"src/init-files/"
]
}

View File

@@ -13,7 +13,6 @@
}, },
"author": "Modern Web <hello@modern-web.dev> (https://modern-web.dev/)", "author": "Modern Web <hello@modern-web.dev> (https://modern-web.dev/)",
"homepage": "https://rocket.modern-web.dev/", "homepage": "https://rocket.modern-web.dev/",
"main": "./exports/index.js",
"type": "module", "type": "module",
"exports": { "exports": {
".": { ".": {
@@ -26,9 +25,10 @@
} }
}, },
"scripts": { "scripts": {
"prepublishOnly": "npm run types",
"test": "mocha --require ../../scripts/testMochaGlobalHooks.js test-node/**/*.test.{js,cjs} test-node/*.test.{js,cjs}", "test": "mocha --require ../../scripts/testMochaGlobalHooks.js test-node/**/*.test.{js,cjs} test-node/*.test.{js,cjs}",
"test:watch": "onchange 'src/**/*.{js,cjs}' 'test-node/**/*.{js,cjs}' -- npm test", "test:watch": "onchange 'src/**/*.{js,cjs}' 'test-node/**/*.{js,cjs}' -- npm test",
"types:copy": "copyfiles \"./types/**/*.d.ts\" dist-types/", "types": "wireit",
"xtest:watch": "mocha test/**/*.test.js --parallel --watch" "xtest:watch": "mocha test/**/*.test.js --parallel --watch"
}, },
"files": [ "files": [
@@ -43,14 +43,21 @@
"dependencies": { "dependencies": {
"@webcomponents/template-shadowroot": "^0.1.0", "@webcomponents/template-shadowroot": "^0.1.0",
"fontawesome-free": "^1.0.4", "fontawesome-free": "^1.0.4",
"lit": "^2.3.0" "lit": "^3.0.0"
}, },
"devDependencies": {}, "devDependencies": {},
"types": "./dist-types/exports/index.d.ts", "types": "./dist-types/exports/index.d.ts",
"typesVersions": { "wireit": {
"*": { "types": {
"*": [ "command": "copyfiles \"./types/**/*.d.ts\" dist-types/ && tsc --build --pretty",
"./dist-types/exports/index.d.ts" "clean": "if-file-deleted",
"files": [
"src/**/*.js",
"tsconfig.json"
],
"output": [
"dist-types/**",
".tsbuildinfo"
] ]
} }
} }

View File

@@ -8,10 +8,14 @@ export class RocketOpenGraphOverview extends LitElement {
constructor() { constructor() {
super(); super();
/** @type {{ url: string, sourceRelativeFilePath: string }} */ this.inputDir = '';
/** @type {{ url: string, sourceRelativeFilePath: string }[]} */
this.pages = []; this.pages = [];
} }
/**
* @param {{ url: string, sourceRelativeFilePath: string }} options
*/
renderPage({ url, sourceRelativeFilePath }) { renderPage({ url, sourceRelativeFilePath }) {
const iframeUrl = url.endsWith('/') const iframeUrl = url.endsWith('/')
? `${url}index.opengraph.html` ? `${url}index.opengraph.html`

View File

@@ -12,6 +12,8 @@ export class RocketRotatingText extends LitElement {
this.initIndex = 0; this.initIndex = 0;
this.inIndex = 0; this.inIndex = 0;
this.outIndex = -1; this.outIndex = -1;
/** @type {string[]} */
this.items = [];
} }
next() { next() {

View File

@@ -5,6 +5,11 @@ export class RocketTestimonialSmall extends LitElement {
cite: { type: String }, cite: { type: String },
}; };
constructor() {
super();
this.cite = '';
}
static styles = css` static styles = css`
:host { :host {
display: block; display: block;

View File

@@ -1,8 +1,15 @@
// @ts-nocheck
import { LitElement, html, css } from 'lit'; import { LitElement, html, css } from 'lit';
// wait for all dialog animations to complete their promises /**
const animationsComplete = element => * Wait for all dialog animations to complete their promises
Promise.allSettled(element.getAnimations().map(animation => animation.finished)); *
* @param {HTMLElement} element
*/
function animationsComplete(element) {
return Promise.allSettled(element.getAnimations().map(animation => animation.finished));
}
export class RocketDialog extends LitElement { export class RocketDialog extends LitElement {
static properties = { static properties = {
@@ -31,6 +38,10 @@ export class RocketDialog extends LitElement {
`; `;
} }
/**
*
* @param {Event} ev
*/
async _submit(ev) { async _submit(ev) {
ev.preventDefault(); ev.preventDefault();
if (ev.target?.value) { if (ev.target?.value) {
@@ -40,8 +51,10 @@ export class RocketDialog extends LitElement {
} }
firstUpdated() { firstUpdated() {
this._dialog = this.shadowRoot.querySelector('dialog'); this._dialog = this.shadowRoot?.querySelector('dialog');
this._invoker = this.shadowRoot.querySelector('slot[name="invoker"]')?.assignedElements()[0]; this._invoker = /** @type {HTMLSlotElement} */ (
this.shadowRoot?.querySelector('slot[name="invoker"]')
)?.assignedElements()[0];
} }
async close() { async close() {

View File

@@ -1,8 +1,13 @@
import { LitElement, html, css } from 'lit'; import { LitElement, html, css } from 'lit';
// wait for all dialog animations to complete their promises /**
const animationsComplete = element => * Wait for all dialog animations to complete their promises
Promise.allSettled(element.getAnimations().map(animation => animation.finished)); *
* @param {HTMLElement} element
*/
function animationsComplete(element) {
return Promise.allSettled(element.getAnimations().map(animation => animation.finished));
}
export class RocketDrawer extends LitElement { export class RocketDrawer extends LitElement {
static properties = { static properties = {
@@ -54,6 +59,9 @@ export class RocketDrawer extends LitElement {
this.open = true; this.open = true;
} }
/**
* @param {import('lit').PropertyValues} changedProperties
*/
updated(changedProperties) { updated(changedProperties) {
super.updated(changedProperties); super.updated(changedProperties);
if (changedProperties.has('open')) { if (changedProperties.has('open')) {
@@ -65,16 +73,24 @@ export class RocketDrawer extends LitElement {
} }
} }
/**
* @param {Event} ev
*/
closeOnOutsideClick(ev) { closeOnOutsideClick(ev) {
if (ev.target === this._dialog) { if (ev.target === this._dialog) {
this.close(); this.close();
} }
} }
/**
* @param {import('lit').PropertyValues} changedProperties
*/
firstUpdated(changedProperties) { firstUpdated(changedProperties) {
super.firstUpdated(changedProperties); super.firstUpdated(changedProperties);
this._dialog = this.shadowRoot.querySelector('dialog'); this._dialog = this.shadowRoot?.querySelector('dialog');
this._invoker = this.shadowRoot.querySelector('slot[name="invoker"]')?.assignedElements()[0]; this._invoker = /** @type {HTMLSlotElement} */ (
this.shadowRoot?.querySelector('slot[name="invoker"]')
)?.assignedElements()[0];
} }
async _close() { async _close() {
@@ -95,8 +111,10 @@ export class RocketDrawer extends LitElement {
this._dialog.dispatchEvent(new Event('opened')); this._dialog.dispatchEvent(new Event('opened'));
this._dialog.removeAttribute('inert'); this._dialog.removeAttribute('inert');
const focusTarget = this.querySelector('[autofocus]'); const focusTarget = /** @type {HTMLElement} */ (this.querySelector('[autofocus]'));
focusTarget ? focusTarget.focus() : this.shadowRoot.querySelector('button.close').focus(); focusTarget
? focusTarget.focus()
: /** @type {HTMLElement} */ (this.shadowRoot?.querySelector('button.close'))?.focus();
} }
} }

View File

@@ -1,4 +1,5 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */ // @ts-nocheck
import { LitElement, html } from 'lit-element'; import { LitElement, html } from 'lit-element';
import { OverlayMixin, withModalDialogConfig } from '@lion/overlays'; import { OverlayMixin, withModalDialogConfig } from '@lion/overlays';

View File

@@ -1,6 +1,8 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */
import { html } from 'lit'; import { html } from 'lit';
/**
* @param {{ pageTree: import('@rocket/engine').PageTree, titleWrapperFn: (input: string) => string, description: string, siteName: string }} options
*/
export function pageDefaults({ pageTree, titleWrapperFn, description, siteName }) { export function pageDefaults({ pageTree, titleWrapperFn, description, siteName }) {
return { return {
...defaultHead({ pageTree, titleWrapperFn, description, siteName }), ...defaultHead({ pageTree, titleWrapperFn, description, siteName }),
@@ -8,14 +10,17 @@ export function pageDefaults({ pageTree, titleWrapperFn, description, siteName }
}; };
} }
/**
* @param {{ pageTree: import('@rocket/engine').PageTree, titleWrapperFn: (input: string) => string, description: string, siteName: string }} options
*/
export function defaultHead({ pageTree, titleWrapperFn, description, siteName }) { export function defaultHead({ pageTree, titleWrapperFn, description, siteName }) {
return { return {
/**
* @param {any} data
*/
head__10: data => { head__10: data => {
const useDescription = data.description ? data.description : description; const useDescription = data.description ? data.description : description;
const title = titleWrapperFn( const title = titleWrapperFn(pageTree.getPage(data.sourceRelativeFilePath)?.model?.name);
// @ts-ignore
pageTree.getPage(data.sourceRelativeFilePath)?.model?.name,
);
return html` return html`
<meta charset="utf-8" /> <meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />

View File

@@ -19,6 +19,13 @@ export class RocketSocialLink extends LitElement {
siteName: { type: String }, siteName: { type: String },
}; };
constructor() {
super();
this.url = '';
this.name = '';
this.siteName = '';
}
render() { render() {
return html` return html`
<a <a

View File

@@ -0,0 +1,15 @@
{
"extends": "../../tsconfig.node-base.json",
"compilerOptions": {
"module": "ESNext",
"outDir": "./dist-types",
"rootDir": ".",
"composite": true,
"allowJs": true,
"checkJs": true,
"emitDeclarationOnly": true,
"moduleResolution": "NodeNext"
},
"include": ["exports", "src", "types"],
"exclude": ["dist-types"]
}

View File

@@ -1,5 +1,11 @@
# @rocket/create # @rocket/create
## 0.1.1
### Patch Changes
- 79e6f0d: Update error message to include an action to resolve a possible [digit error](https://github.com/Rich-Harris/degit/issues/313).
## 0.1.0 ## 0.1.0
### Minor Changes ### Minor Changes

View File

@@ -1,6 +1,6 @@
{ {
"name": "@rocket/create", "name": "@rocket/create",
"version": "0.1.0", "version": "0.1.1",
"publishConfig": { "publishConfig": {
"access": "public" "access": "public"
}, },
@@ -13,7 +13,6 @@
}, },
"author": "Modern Web <hello@modern-web.dev> (https://modern-web.dev/)", "author": "Modern Web <hello@modern-web.dev> (https://modern-web.dev/)",
"homepage": "https://rocket.modern-web.dev/", "homepage": "https://rocket.modern-web.dev/",
"main": "./src/index.js",
"bin": { "bin": {
"create-rocket": "src/cli.js" "create-rocket": "src/cli.js"
}, },
@@ -28,8 +27,7 @@
"prepublishOnly": "node ./scripts/prepublish.js", "prepublishOnly": "node ./scripts/prepublish.js",
"start": "node ./src/cli.js", "start": "node ./src/cli.js",
"test": "mocha test-node/**/*.test.{js,cjs} test-node/*.test.{js,cjs}", "test": "mocha test-node/**/*.test.{js,cjs} test-node/*.test.{js,cjs}",
"test:watch": "onchange 'src/**/*.{js,cjs}' 'test-node/**/*.{js,cjs}' -- npm test", "test:watch": "onchange 'src/**/*.{js,cjs}' 'test-node/**/*.{js,cjs}' -- npm test"
"types:copy": "copyfiles \"./types/**/*.d.ts\" dist-types/"
}, },
"files": [ "files": [
"deployments", "deployments",
@@ -49,13 +47,5 @@
"commander": "^9.0.0", "commander": "^9.0.0",
"degit": "^2.0.0", "degit": "^2.0.0",
"prompts": "^2.2.0" "prompts": "^2.2.0"
},
"types": "./dist-types/src/index.d.ts",
"typesVersions": {
"*": {
"*": [
"./dist-types/src/index.d.ts"
]
}
} }
} }

View File

@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */
import { Command } from 'commander'; import { Command } from 'commander';
import prompts from 'prompts'; import prompts from 'prompts';
import { underline, bold, gray, green, blue, yellow, red } from 'colorette'; import { underline, bold, gray, green, blue, yellow, red } from 'colorette';
@@ -152,7 +151,11 @@ export class CreateCli {
await gitHandler.clone('./' + newFolderPath); await gitHandler.clone('./' + newFolderPath);
cloneError = false; cloneError = false;
} catch (e) { } catch (e) {
console.log(`${red('✖')} Could not apply the template - maybe the url is wrong?`); console.log(
`${red(
'✖',
)} Could not apply the template - maybe the url is wrong? If this problem persists, you could try clearing your .degit cache, usually located at ~/.degit`,
);
console.log(`${red('>')} ${e.message}`); console.log(`${red('>')} ${e.message}`);
const response = await prompts({ const response = await prompts({
type: 'text', type: 'text',

View File

@@ -13,7 +13,6 @@
}, },
"author": "Modern Web <hello@modern-web.dev> (https://modern-web.dev/)", "author": "Modern Web <hello@modern-web.dev> (https://modern-web.dev/)",
"homepage": "https://rocket.modern-web.dev/docs/tools/engine/", "homepage": "https://rocket.modern-web.dev/docs/tools/engine/",
"main": "./src/index.js",
"type": "module", "type": "module",
"exports": { "exports": {
".": { ".": {
@@ -33,12 +32,13 @@
} }
}, },
"scripts": { "scripts": {
"debug": "DEBUG=engine:rendering yarn test", "debug": "DEBUG=engine:rendering npm run test",
"debug:integration": "PWDEBUG=1 yarn test:integration", "debug:integration": "PWDEBUG=1 npm run test:integration",
"prepublishOnly": "npm run types",
"test": "mocha --require ../../scripts/testMochaGlobalHooks.js --timeout 8000 test-node/**/*.test.js test-node/*.test.js", "test": "mocha --require ../../scripts/testMochaGlobalHooks.js --timeout 8000 test-node/**/*.test.js test-node/*.test.js",
"test:integration": "playwright test test-node/*.spec.js --retries=3", "test:integration": "playwright test test-node/*.spec.js --retries=3",
"test:watch": "onchange 'src/**/*.js' 'test-node/**/*.js' -- npm test", "test:watch": "onchange 'src/**/*.js' 'test-node/**/*.js' -- npm test",
"types:copy": "copyfiles \"./types/**/*.d.ts\" dist-types/" "types": "wireit"
}, },
"files": [ "files": [
"assets", "assets",
@@ -47,27 +47,31 @@
], ],
"dependencies": { "dependencies": {
"@d4kmor/tree-model": "^0.1.3", "@d4kmor/tree-model": "^0.1.3",
"@lit-labs/ssr": "^2.2.3", "@lit-labs/ssr": "^3.0.0",
"@mdjs/core": "^0.20.0", "@mdjs/core": "^0.20.0",
"@parcel/watcher": "^2.0.5", "@parcel/watcher": "^2.0.5",
"@web/dev-server": "^0.1.4", "@web/dev-server": "^0.1.4",
"es-module-lexer": "^0.10.5", "es-module-lexer": "^0.10.5",
"lit": "^2.3.0", "lit": "^3.0.0",
"plugins-manager": "^0.3.0", "plugins-manager": "^0.3.0",
"sax-wasm": "^2.1.3", "sax-wasm": "^2.1.3",
"unist-util-visit": "^4.1.0" "unist-util-visit": "^4.1.0"
}, },
"types": "./dist-types/src/index.d.ts", "wireit": {
"typesVersions": { "types": {
"*": { "command": "copyfiles \"./types/**/*.d.ts\" dist-types/ && tsc --build --pretty",
"*": [ "dependencies": [
"./dist-types/src/index.d.ts" "../plugins-manager:types",
"../mdjs-core:types"
], ],
"server": [ "clean": "if-file-deleted",
"./dist-types/src/index.server.d.ts" "files": [
"src/**/*.js",
"tsconfig.json"
], ],
"hydration": [ "output": [
"./dist-types/src/index.hydration.d.ts" "dist-types/**",
".tsbuildinfo"
] ]
} }
} }

View File

@@ -1,5 +1,3 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */
/** @typedef {import('../types/main.js').EngineOptions} EngineOptions */ /** @typedef {import('../types/main.js').EngineOptions} EngineOptions */
/** @typedef {import('../types/main.js').DevServerPlugin} DevServerPlugin */ /** @typedef {import('../types/main.js').DevServerPlugin} DevServerPlugin */
/** @typedef {import('../types/main.js').DevServerMiddleware} DevServerMiddleware */ /** @typedef {import('../types/main.js').DevServerMiddleware} DevServerMiddleware */
@@ -393,11 +391,6 @@ export class Engine {
return await urlToSourceFilePath(url, this.docsDir); return await urlToSourceFilePath(url, this.docsDir);
} }
/**
* @param {object} [options]
* @param {string} [options.triggerSourceFilePath]
* @param {boolean} [options.deleteOtherFiles]
*/
async renderAllOpenedFiles({ deleteOtherFiles = true, triggerSourceFilePath = '' } = {}) { async renderAllOpenedFiles({ deleteOtherFiles = true, triggerSourceFilePath = '' } = {}) {
if (this.watcher) { if (this.watcher) {
for (const [sourceFilePath, page] of this.watcher.pages.entries()) { for (const [sourceFilePath, page] of this.watcher.pages.entries()) {

View File

@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */
import { existsSync } from 'fs'; import { existsSync } from 'fs';
import path from 'path'; import path from 'path';
import { debuglog } from 'util'; import { debuglog } from 'util';

View File

@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */
import { existsSync } from 'fs'; import { existsSync } from 'fs';
import { readFile, writeFile } from 'fs/promises'; import { readFile, writeFile } from 'fs/promises';
import path from 'path'; import path from 'path';
@@ -191,11 +190,14 @@ export class RocketHeader {
const [, exports] = parse(readDataFile.toString()); const [, exports] = parse(readDataFile.toString());
for (const dataExportName of exports) { for (const dataExportName of exports) {
// TODO: update to latest es-module-lexer version
// @ts-ignore - ts somehow grabs the wrong version of es-module-lexer types... 0.x => strings[], 1.x => {...}[]
const foundIndex = possibleImports.findIndex(el => el.importName === dataExportName); const foundIndex = possibleImports.findIndex(el => el.importName === dataExportName);
if (foundIndex >= 0) { if (foundIndex >= 0) {
possibleImports[foundIndex].importModuleName = exportModuleName; possibleImports[foundIndex].importModuleName = exportModuleName;
} else { } else {
possibleImports.push({ possibleImports.push({
// @ts-ignore
importName: dataExportName, importName: dataExportName,
importModuleName: exportModuleName, importModuleName: exportModuleName,
}); });

View File

@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */
// @ts-ignore // @ts-ignore
import { mdjsProcess } from '@mdjs/core'; import { mdjsProcess } from '@mdjs/core';
import { existsSync } from 'fs'; import { existsSync } from 'fs';

View File

@@ -1,21 +1,20 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */
/* eslint-disable no-prototype-builtins */ /* eslint-disable no-prototype-builtins */
import { evaluate } from './evaluate.js'; import { evaluate } from './evaluate.js';
import { extractStrategies } from './extractStrategies.js'; import { extractStrategies } from './extractStrategies.js';
export class HydrationLoader { export class HydrationLoader {
/** @type {import('../../types/main').Components} */ /** @type {import('../../types/main.js').Components} */
components = {}; components = {};
isSetup = false; isSetup = false;
/** @type {import('../../types/main').ElementWithStrategy[]} */ /** @type {import('../../types/main.js').ElementWithStrategy[]} */
elements = []; elements = [];
/** @type {{ [key: string]: MediaQueryList }} */ /** @type {{ [key: string]: MediaQueryList }} */
mediaQueries = {}; mediaQueries = {};
/** /**
* @param {import('../../types/main').Components} components * @param {import('../../types/main.js').Components} components
*/ */
constructor(components) { constructor(components) {
this.components = components; this.components = components;
@@ -81,11 +80,11 @@ export class HydrationLoader {
} }
/** /**
* @returns {import('../../types/main').ElementWithStrategy[]} * @returns {import('../../types/main.js').ElementWithStrategy[]}
*/ */
gatherElements() { gatherElements() {
const els = document.querySelectorAll('[loading]'); const els = document.querySelectorAll('[loading]');
/** @type {import('../../types/main').ElementWithStrategy[]} */ /** @type {import('../../types/main.js').ElementWithStrategy[]} */
const elements = []; const elements = [];
for (const el of els) { for (const el of els) {
const strategyAttribute = el.getAttribute('loading'); const strategyAttribute = el.getAttribute('loading');
@@ -268,7 +267,9 @@ export class HydrationLoader {
if (this.isSetup === false) { if (this.isSetup === false) {
// Start fetching the Lit hydration support module (note the absence // Start fetching the Lit hydration support module (note the absence
// of "await" -- we don't want to block yet). // of "await" -- we don't want to block yet).
const litHydrateSupportInstalled = import('lit/experimental-hydrate-support.js'); const litHydrateSupportInstalled = import(
'@lit-labs/ssr-client/lit-element-hydrate-support.js'
);
// Check if we require the declarative shadow DOM polyfill. As of // Check if we require the declarative shadow DOM polyfill. As of
// February 2022, Chrome and Edge have native support, but Firefox // February 2022, Chrome and Edge have native support, but Firefox

View File

@@ -1,9 +1,7 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */
/** /**
* @param {object} options * @param {object} options
* @param {string} options.strategyTemplate * @param {string} options.strategyTemplate
* @param {import("../../types/main").Strategy[]} options.strategies * @param {import("../../types/main.js").Strategy[]} options.strategies
* @returns {boolean} * @returns {boolean}
*/ */
export function evaluate({ strategyTemplate, strategies }) { export function evaluate({ strategyTemplate, strategies }) {

View File

@@ -49,12 +49,12 @@ function getStrategy(part, type) {
/** /**
* @param {string} input * @param {string} input
* @returns {import("../../types/main").LoadingStrategy} * @returns {import("../../types/main.js").LoadingStrategy}
*/ */
export function extractStrategies(input) { export function extractStrategies(input) {
const parts = getParts(input); const parts = getParts(input);
/** @type {import("../../types/main").LoadingStrategy} */ /** @type {import("../../types/main.js").LoadingStrategy} */
const result = { const result = {
strategyAttribute: input, strategyAttribute: input,
strategies: [], strategies: [],

View File

@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */
import { renderJoiningGroup } from '../helpers/renderJoiningGroup.js'; import { renderJoiningGroup } from '../helpers/renderJoiningGroup.js';
import { html } from 'lit'; import { html } from 'lit';
import { classMap } from 'lit/directives/class-map.js'; import { classMap } from 'lit/directives/class-map.js';

View File

@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */
/** @typedef {import('lit').TemplateResult} TemplateResult */ /** @typedef {import('lit').TemplateResult} TemplateResult */
export class LayoutRaw { export class LayoutRaw {

View File

@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */
// @ts-nocheck // @ts-nocheck
import path from 'path'; import path from 'path';
import { TreeModel } from '@d4kmor/tree-model'; import { TreeModel } from '@d4kmor/tree-model';

View File

@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */
import { Menu } from './Menu.js'; import { Menu } from './Menu.js';
/** @typedef {import('lit').TemplateResult} TemplateResult */ /** @typedef {import('lit').TemplateResult} TemplateResult */

View File

@@ -86,7 +86,7 @@ async function renderFile({
openGraphUrl: url.replace(/\.html$/, '.opengraph.html'), openGraphUrl: url.replace(/\.html$/, '.opengraph.html'),
}; };
} }
/** @type {import('../../types/layout').renderData} */ /** @type {import('../../types/layout.js').renderData} */
const layoutData = { const layoutData = {
sourceFilePath, sourceFilePath,
outputFilePath, outputFilePath,

View File

@@ -1,5 +1,3 @@
// Don't edit this file directly. It is generated by /scripts/update-package-configs.ts
{ {
"extends": "../../tsconfig.node-base.json", "extends": "../../tsconfig.node-base.json",
"compilerOptions": { "compilerOptions": {
@@ -9,24 +7,10 @@
"composite": true, "composite": true,
"allowJs": true, "allowJs": true,
"checkJs": true, "checkJs": true,
"emitDeclarationOnly": true "emitDeclarationOnly": true,
"moduleResolution": "NodeNext"
}, },
"references": [ "references": [],
{ "include": ["src", "types"],
"path": "../plugins-manager/tsconfig.json" "exclude": ["dist-types"]
}, }
{
"path": "../mdjs-core/tsconfig.json"
}
],
"include": [
"src",
"*.js",
"types",
"preset"
],
"exclude": [
"dist",
"dist-types"
]
}

View File

@@ -1,3 +0,0 @@
{
"include": ["src", "*.js", "types", "preset"]
}

View File

@@ -1,5 +1,13 @@
# @rocket/launch # @rocket/launch
## 0.21.3
### Patch Changes
- 660f64c: Change the default gitBranch to main
- Updated dependencies [68e05f4]
- @rocket/cli@0.20.4
## 0.21.2 ## 0.21.2
### Patch Changes ### Patch Changes

View File

@@ -1 +0,0 @@
export { LaunchContent } from '../src/content/LaunchContent.js';

View File

@@ -1,6 +1,6 @@
{ {
"name": "@rocket/launch", "name": "@rocket/launch",
"version": "0.21.2", "version": "0.21.3",
"publishConfig": { "publishConfig": {
"access": "public" "access": "public"
}, },
@@ -13,7 +13,6 @@
}, },
"author": "Modern Web <hello@modern-web.dev> (https://modern-web.dev/)", "author": "Modern Web <hello@modern-web.dev> (https://modern-web.dev/)",
"homepage": "https://rocket.modern-web.dev/docs/presets/launch/", "homepage": "https://rocket.modern-web.dev/docs/presets/launch/",
"main": "./src/index.js",
"type": "module", "type": "module",
"exports": { "exports": {
".": { ".": {
@@ -23,13 +22,17 @@
"./assets/*": "./assets/*", "./assets/*": "./assets/*",
"./css/*": "./css/*", "./css/*": "./css/*",
"./js/*": "./src/public/*", "./js/*": "./src/public/*",
"./*": "./exports/*" "./*": {
"types": "./dist-types/exports/*",
"default": "./exports/*"
}
}, },
"scripts": { "scripts": {
"analyze": "cem analyze --litelement", "analyze": "cem analyze --litelement",
"prepublishOnly": "npm run types",
"test": "mocha --timeout 5000 test-node/**/*.test.{js,cjs} test-node/*.test.{js,cjs}", "test": "mocha --timeout 5000 test-node/**/*.test.{js,cjs} test-node/*.test.{js,cjs}",
"test:watch": "onchange 'src/**/*.{js,cjs}' 'test-node/**/*.{js,cjs}' -- npm test", "test:watch": "onchange 'src/**/*.{js,cjs}' 'test-node/**/*.{js,cjs}' -- npm test",
"types:copy": "copyfiles \"./types/**/*.d.ts\" dist-types/" "types": "wireit"
}, },
"files": [ "files": [
"__public", "__public",
@@ -46,22 +49,32 @@
"preset" "preset"
], ],
"dependencies": { "dependencies": {
"@rocket/cli": "^0.20.3", "@rocket/cli": "^0.20.4",
"@rocket/components": "^0.2.0", "@rocket/components": "^0.2.0",
"@rocket/engine": "^0.2.7", "@rocket/engine": "^0.2.7",
"@webcomponents/template-shadowroot": "^0.1.0", "@webcomponents/template-shadowroot": "^0.1.0",
"lit": "^2.3.0", "lit": "^3.0.0",
"plugins-manager": "^0.3.1",
"workbox-window": "^6.1.5" "workbox-window": "^6.1.5"
}, },
"types": "./dist-types/src/index.d.ts",
"customElements": "custom-elements.json", "customElements": "custom-elements.json",
"typesVersions": { "wireit": {
"*": { "types": {
"*": [ "command": "copyfiles \"./types/**/*.d.ts\" dist-types/ && tsc --build --pretty",
"./dist-types/src/index.d.ts" "dependencies": [
"../cli:types",
"../components:types",
"../engine:types",
"../plugins-manager:types"
], ],
"inline-notification": [ "clean": "if-file-deleted",
"./dist-types/src/inline-notification/index.d.ts" "files": [
"src/**/*.js",
"tsconfig.json"
],
"output": [
"dist-types/**",
".tsbuildinfo"
] ]
} }
} }

View File

@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */
import { renderJoiningGroup, TableOfContentsMenu } from '@rocket/engine'; import { renderJoiningGroup, TableOfContentsMenu } from '@rocket/engine';
import { html } from 'lit'; import { html } from 'lit';
import { LayoutMain } from './LayoutMain.js'; import { LayoutMain } from './LayoutMain.js';

View File

@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */
import { renderJoiningGroup } from '@rocket/engine'; import { renderJoiningGroup } from '@rocket/engine';
import { html, nothing } from 'lit'; import { html, nothing } from 'lit';
import { LayoutMain } from './LayoutMain.js'; import { LayoutMain } from './LayoutMain.js';

View File

@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */
import { import {
Layout, Layout,
renderJoiningGroup, renderJoiningGroup,
@@ -57,7 +56,7 @@ export class LayoutMain extends Layout {
</picture> </picture>
`, `,
gitSiteUrl: 'https://github.com/modernweb-dev/rocket', gitSiteUrl: 'https://github.com/modernweb-dev/rocket',
gitBranch: 'next', gitBranch: 'main',
description: 'A static site generator for modern web development', description: 'A static site generator for modern web development',
socialLinks: [ socialLinks: [
{ {

View File

@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */
import { renderJoiningGroup, TableOfContentsMenu } from '@rocket/engine'; import { renderJoiningGroup, TableOfContentsMenu } from '@rocket/engine';
import { html } from 'lit'; import { html } from 'lit';
import { LayoutMain } from './LayoutMain.js'; import { LayoutMain } from './LayoutMain.js';

View File

@@ -3,6 +3,6 @@ export const defaultGlobalOptions = {
logoSrc: '/icon.svg', logoSrc: '/icon.svg',
logoAlt: 'Rocket Logo', logoAlt: 'Rocket Logo',
gitSiteUrl: 'https://github.com/modernweb-dev/rocket', gitSiteUrl: 'https://github.com/modernweb-dev/rocket',
gitBranch: 'master', gitBranch: 'main',
description: 'A static site generator for modern web development', description: 'A static site generator for modern web development',
}; };

View File

@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */
import { LitElement, html, nothing } from 'lit'; import { LitElement, html, nothing } from 'lit';
import { LaunchBlogPreview } from './LaunchBlogPreview.js'; import { LaunchBlogPreview } from './LaunchBlogPreview.js';

View File

@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */
(async () => { (async () => {
if ('serviceWorker' in navigator) { if ('serviceWorker' in navigator) {
const { Workbox } = await import('workbox-window'); const { Workbox } = await import('workbox-window');

View File

@@ -5,7 +5,6 @@ import { BroadcastUpdatePlugin } from 'workbox-broadcast-update';
import { ExpirationPlugin } from 'workbox-expiration'; import { ExpirationPlugin } from 'workbox-expiration';
addEventListener('install', () => { addEventListener('install', () => {
/* eslint-disable @typescript-eslint/ban-ts-comment */
// @ts-ignore // @ts-ignore
skipWaiting(); skipWaiting();
/* eslint-enable @typescript-eslint/ban-ts-comment */ /* eslint-enable @typescript-eslint/ban-ts-comment */

View File

@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */
import { addPlugin } from 'plugins-manager'; import { addPlugin } from 'plugins-manager';
class EnginePluginLaunch { class EnginePluginLaunch {

View File

@@ -1,5 +1,3 @@
// Don't edit this file directly. It is generated by /scripts/update-package-configs.ts
{ {
"extends": "../../tsconfig.node-base.json", "extends": "../../tsconfig.node-base.json",
"compilerOptions": { "compilerOptions": {
@@ -9,29 +7,9 @@
"composite": true, "composite": true,
"allowJs": true, "allowJs": true,
"checkJs": true, "checkJs": true,
"emitDeclarationOnly": true "emitDeclarationOnly": true,
"moduleResolution": "NodeNext"
}, },
"references": [ "include": ["exports", "src", "types"],
{ "exclude": ["dist-types", "**/__output/**", "**/__output-dev/**"]
"path": "../plugins-manager/tsconfig.json" }
},
{
"path": "../mdjs-core/tsconfig.json"
},
{
"path": "../engine/tsconfig.json"
},
{
"path": "../cli/tsconfig.json"
}
],
"include": [
"src",
"*.js",
"types"
],
"exclude": [
"dist",
"dist-types"
]
}

Some files were not shown because too many files have changed in this diff Show More