зеркало из https://github.com/github/docs.git
Next12 now supports ESM (#29295)
* Next12 now supports ESM * No more michael jackson script extensions * Fix test running * Update jest-puppeteer.config.cjs * Update package.json
This commit is contained in:
Родитель
d1ea358256
Коммит
2182ff28f3
|
@ -1 +0,0 @@
|
|||
{"type":"module"}
|
|
@ -62,7 +62,7 @@ jobs:
|
|||
# Don't care about CDN caching image URLs
|
||||
DISABLE_REWRITE_ASSET_URLS: true
|
||||
run: |
|
||||
node server.mjs > /tmp/stdout.log 2> /tmp/stderr.log &
|
||||
node server.js > /tmp/stdout.log 2> /tmp/stderr.log &
|
||||
sleep 6
|
||||
curl --retry-connrefused --retry 5 -I http://localhost:4000/
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ jobs:
|
|||
DISABLE_RENDERING_CACHE: true
|
||||
run: |
|
||||
|
||||
node server.mjs &
|
||||
node server.js &
|
||||
sleep 5
|
||||
curl --retry-connrefused --retry 3 -I http://localhost:4000/
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ on:
|
|||
- '**.yaml'
|
||||
- '**.yml'
|
||||
- '**.scss'
|
||||
- .eslintrc.js
|
||||
- .eslintrc.cjs
|
||||
# In case something like eslint or tsc or prettier upgrades
|
||||
- 'package-lock.json'
|
||||
# Ultimately, for debugging this workflow itself
|
||||
|
|
|
@ -10,7 +10,7 @@ on:
|
|||
- gh-readonly-queue/main/**
|
||||
pull_request:
|
||||
paths:
|
||||
- script/search/index-elasticsearch.mjs
|
||||
- script/search/index-elasticsearch.js
|
||||
- 'package*.json'
|
||||
- .github/workflows/dry-run-elasticsearch-indexing.yml
|
||||
|
||||
|
@ -63,7 +63,7 @@ jobs:
|
|||
env:
|
||||
ELASTICSEARCH_URL: 'http://localhost:9200'
|
||||
run: |
|
||||
./script/search/index-elasticsearch.mjs --verbose \
|
||||
./script/search/index-elasticsearch.js --verbose \
|
||||
-l en -l ja \
|
||||
-V dotcom -V ghes-3.5
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ jobs:
|
|||
# Don't care about CDN caching image URLs
|
||||
DISABLE_REWRITE_ASSET_URLS: true
|
||||
run: |
|
||||
./script/rendered-content-link-checker.mjs \
|
||||
./script/rendered-content-link-checker.js \
|
||||
--language en \
|
||||
--max 100 \
|
||||
--check-anchors \
|
||||
|
@ -66,7 +66,7 @@ jobs:
|
|||
# Don't care about CDN caching image URLs
|
||||
DISABLE_REWRITE_ASSET_URLS: true
|
||||
run: |
|
||||
./script/rendered-content-link-checker.mjs \
|
||||
./script/rendered-content-link-checker.js \
|
||||
--language en \
|
||||
--exit \
|
||||
--verbose \
|
||||
|
|
|
@ -40,7 +40,7 @@ jobs:
|
|||
run: |
|
||||
set -e
|
||||
|
||||
./script/find-orphaned-assets.mjs | xargs git rm
|
||||
./script/find-orphaned-assets.js | xargs git rm
|
||||
|
||||
# If nothing to commit, exit now. It's fine. No orphans.
|
||||
git status | grep 'nothing to commit' && exit 0
|
||||
|
@ -58,6 +58,6 @@ jobs:
|
|||
|
||||
gh pr create \
|
||||
--title "Delete orphaned assets ($date)" \
|
||||
--body "Found with the find-orphaned-assets.mjs script" \
|
||||
--body "Found with the find-orphaned-assets.js script" \
|
||||
--repo github/docs-internal \
|
||||
--label docs-content-fr
|
||||
|
|
|
@ -109,7 +109,7 @@ jobs:
|
|||
|
||||
- name: Index into Elasticsearch
|
||||
run: |
|
||||
./script/search/index-elasticsearch.mjs \
|
||||
./script/search/index-elasticsearch.js \
|
||||
--language ${{ matrix.language }} \
|
||||
--source-directory /tmp/records
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ ENV NODE_ENV production
|
|||
# Whether to hide iframes, add warnings to external links
|
||||
ENV AIRGAP false
|
||||
|
||||
# Preferred port for server.mjs
|
||||
# Preferred port for server.js
|
||||
ENV PORT 4000
|
||||
|
||||
ENV ENABLED_LANGUAGES "en"
|
||||
|
@ -94,12 +94,12 @@ COPY --chown=node:node middleware ./middleware
|
|||
COPY --chown=node:node feature-flags.json ./
|
||||
COPY --chown=node:node data ./data
|
||||
COPY --chown=node:node next.config.js ./
|
||||
COPY --chown=node:node server.mjs ./server.mjs
|
||||
COPY --chown=node:node start-server.mjs ./start-server.mjs
|
||||
COPY --chown=node:node server.js ./server.js
|
||||
COPY --chown=node:node start-server.js ./start-server.js
|
||||
|
||||
EXPOSE $PORT
|
||||
|
||||
CMD ["node", "server.mjs"]
|
||||
CMD ["node", "server.js"]
|
||||
|
||||
# --------------------------------------------------------------------------------
|
||||
# PRODUCTION IMAGE - includes all translations
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
{"type":"module"}
|
|
@ -13,7 +13,7 @@ if (testTranslation) {
|
|||
reporters.push('jest-github-actions-reporter')
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
coverageThreshold: {
|
||||
global: {
|
||||
branches: 95,
|
||||
|
@ -41,6 +41,6 @@ module.exports = {
|
|||
],
|
||||
testMatch: ['**/tests/**/*.js'],
|
||||
testLocationInResults: isActions,
|
||||
globalSetup: './script/start-server-for-jest.mjs',
|
||||
globalTeardown: './script/kill-server-for-jest.mjs',
|
||||
globalSetup: './script/start-server-for-jest.js',
|
||||
globalTeardown: './script/kill-server-for-jest.js',
|
||||
}
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
{"type":"module"}
|
|
@ -1 +0,0 @@
|
|||
{"type":"module"}
|
|
@ -1,14 +1,11 @@
|
|||
// import { productIds } from './lib/all-products.js'
|
||||
// import languages from './lib/languages.js'
|
||||
|
||||
const fs = require('fs')
|
||||
const frontmatter = require('gray-matter')
|
||||
const path = require('path')
|
||||
import fs from 'fs'
|
||||
import frontmatter from 'gray-matter'
|
||||
import path from 'path'
|
||||
const homepage = path.posix.join(process.cwd(), 'content/index.md')
|
||||
const { data } = frontmatter(fs.readFileSync(homepage, 'utf8'))
|
||||
const productIds = data.children
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
// speed up production `next build` by ignoring typechecking during that step of build.
|
||||
// type-checking still occurs in the Dockerfile build
|
||||
typescript: {
|
||||
|
|
17
package.json
17
package.json
|
@ -169,7 +169,7 @@
|
|||
"engines": {
|
||||
"node": ">=16.x"
|
||||
},
|
||||
"exports": "./server.mjs",
|
||||
"exports": "./server.js",
|
||||
"license": "(MIT AND CC-BY-4.0)",
|
||||
"name": "docs.github.com",
|
||||
"optionalDependencies": {
|
||||
|
@ -183,9 +183,9 @@
|
|||
"private": true,
|
||||
"repository": "https://github.com/github/docs",
|
||||
"scripts": {
|
||||
"browser-test": "cross-env BROWSER=1 NODE_OPTIONS=--experimental-vm-modules jest tests/browser/browser.js",
|
||||
"browser-test": "cross-env BROWSER=1 NODE_OPTIONS=--experimental-vm-modules JEST_PUPPETEER_CONFIG=jest-puppeteer.config.cjs jest tests/browser/browser.js",
|
||||
"build": "next build",
|
||||
"debug": "cross-env NODE_ENV=development ENABLED_LANGUAGES='en,ja' nodemon --inspect server.mjs",
|
||||
"debug": "cross-env NODE_ENV=development ENABLED_LANGUAGES='en,ja' nodemon --inspect server.js",
|
||||
"dev": "npm start",
|
||||
"lint": "eslint '**/*.{js,mjs,ts,tsx}'",
|
||||
"lint-translation": "cross-env NODE_OPTIONS=--experimental-vm-modules TEST_TRANSLATION=true jest tests/linting/lint-files.js",
|
||||
|
@ -195,14 +195,14 @@
|
|||
"prevent-pushes-to-main": "node script/prevent-pushes-to-main.js",
|
||||
"rest-dev": "script/rest/update-files.js && npm run dev",
|
||||
"show-action-deps": "echo 'Action Dependencies:' && rg '^[\\s|-]*(uses:.*)$' .github -I -N --no-heading -r '$1$2' | sort | uniq | cut -c 7-",
|
||||
"start": "cross-env NODE_ENV=development ENABLED_LANGUAGES='en,ja' nodemon server.mjs",
|
||||
"start-all-languages": "cross-env NODE_ENV=development nodemon server.mjs",
|
||||
"start": "cross-env NODE_ENV=development ENABLED_LANGUAGES='en,ja' nodemon server.js",
|
||||
"start-all-languages": "cross-env NODE_ENV=development nodemon server.js",
|
||||
"sync-search": "cross-env NODE_OPTIONS='--max_old_space_size=8192' start-server-and-test sync-search-server 4002 sync-search-indices",
|
||||
"sync-search-ghes-release": "cross-env GHES_RELEASE=1 start-server-and-test sync-search-server 4002 sync-search-indices",
|
||||
"sync-search-indices": "script/search/sync-search-indices.js",
|
||||
"sync-search-server": "cross-env NODE_ENV=production PORT=4002 CHANGELOG_DISABLED=true DISABLE_RENDERING_CACHE=true DISABLE_OVERLOAD_PROTECTION=true node server.mjs",
|
||||
"sync-search-server": "cross-env NODE_ENV=production PORT=4002 CHANGELOG_DISABLED=true DISABLE_RENDERING_CACHE=true DISABLE_OVERLOAD_PROTECTION=true node server.js",
|
||||
"translation-check": "start-server-and-test translation-check-server 4002 translation-check-test",
|
||||
"translation-check-server": "cross-env NODE_ENV=test PORT=4002 node server.mjs",
|
||||
"translation-check-server": "cross-env NODE_ENV=test PORT=4002 node server.js",
|
||||
"translation-check-test": "script/i18n/test-html-pages.js",
|
||||
"test": "cross-env NODE_OPTIONS='--max_old_space_size=4096 --experimental-vm-modules' jest --logHeapUsage",
|
||||
"test-watch": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --watch --notify --notifyMode=change --coverage",
|
||||
|
@ -211,5 +211,6 @@
|
|||
"lint-staged": {
|
||||
"*.{js,mjs,ts,tsx}": "eslint --cache --fix",
|
||||
"*.{js,mjs,scss,ts,tsx,yml,yaml}": "prettier --write"
|
||||
}
|
||||
},
|
||||
"type": "module"
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
import teardownJestPuppeteer from 'jest-environment-puppeteer/teardown.js'
|
||||
|
||||
import { START_JEST_SERVER, isServerHealthy, killServer } from './server-for-jest.mjs'
|
||||
import { START_JEST_SERVER, isServerHealthy, killServer } from './server-for-jest.js'
|
||||
|
||||
export default async () => {
|
||||
if (START_JEST_SERVER) {
|
|
@ -1 +0,0 @@
|
|||
{"type":"module"}
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
import setupJestPuppeteer from 'jest-environment-puppeteer/setup.js'
|
||||
|
||||
import { main } from '../start-server.mjs'
|
||||
import { main } from '../start-server.js'
|
||||
|
||||
import { PORT, START_JEST_SERVER, isServerHealthy, isPortRunning } from './server-for-jest.mjs'
|
||||
import { PORT, START_JEST_SERVER, isServerHealthy, isPortRunning } from './server-for-jest.js'
|
||||
|
||||
export default async () => {
|
||||
if (START_JEST_SERVER) {
|
|
@ -0,0 +1,3 @@
|
|||
import { main } from './start-server.js'
|
||||
|
||||
main()
|
|
@ -1,3 +0,0 @@
|
|||
import { main } from './start-server.mjs'
|
||||
|
||||
main()
|
|
@ -89,7 +89,7 @@ since the server won't need to start and stop every time you run tests.
|
|||
In one terminal type:
|
||||
|
||||
```sh
|
||||
NODE_ENV=test PORT=4000 node server.mjs
|
||||
NODE_ENV=test PORT=4000 node server.js
|
||||
```
|
||||
|
||||
and then, in another terminal type:
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
{"type":"module"}
|
|
@ -1029,7 +1029,7 @@ describe('static routes', () => {
|
|||
it('does not serve repo contents that live outside the /assets directory', async () => {
|
||||
expect((await get('/package.json', { followRedirects: true })).statusCode).toBe(404)
|
||||
expect((await get('/README.md', { followRedirects: true })).statusCode).toBe(404)
|
||||
expect((await get('/server.mjs', { followRedirects: true })).statusCode).toBe(404)
|
||||
expect((await get('/server.js', { followRedirects: true })).statusCode).toBe(404)
|
||||
})
|
||||
})
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче