Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Transfer oss docs #210

Merged
merged 18 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
30 changes: 4 additions & 26 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,9 @@
const fs = require('fs');
const graphql = require('graphql');
const gatsbyESLintConfig = require('gatsby/dist/utils/eslint-config');
const gatsbyWebpackUtils = require('gatsby/dist/utils/webpack-utils');

const graphQLSchema = (() => {
let str;
try {
str = fs.readFileSync('./schema.graphql').toString();
} catch (err) {
console.log("Warning: File ./schema.graphql does not exist;\n"+
" ESLint output regarding GraphQL queries may be inaccurate.\n"+
" Run a Gatsby command to generate the schema file.")
str = "type Query {\n\tempty(filter: Int!): Int\n}\n";
}
return graphql.buildSchema(str);
})();
const usingJSXRuntime = gatsbyWebpackUtils.reactHasJsxRuntime();

const baseConfig = gatsbyESLintConfig.eslintConfig(graphQLSchema, usingJSXRuntime).baseConfig;

module.exports = {
...baseConfig,

globals: {
__PATH_PREFIX__: true,
},
extends: `react-app`,
ignorePatterns: [
"/public/",
],
rules: {
...baseConfig.rules,
},
};
12 changes: 4 additions & 8 deletions .github/workflows/blc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,12 @@ jobs:
"Check":
runs-on: ubuntu-latest
steps:
- uses: actions/setup-node@v2
with:
node-version: '16'
- uses: actions/setup-python@v2
with:
python-version: '^3.9'
- uses: actions/checkout@v2
- uses: actions/setup-node@v4
- uses: actions/setup-python@v5
- uses: actions/checkout@v4
with:
path: site
- uses: actions/checkout@master
- uses: actions/checkout@v4
with:
repository: datawire/getambassador.io-blc2
path: blc
Expand Down
10 changes: 3 additions & 7 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,13 @@ jobs:
"Lint":
runs-on: ubuntu-latest
steps:
- uses: actions/setup-node@v2
with:
node-version: '16'
- uses: actions/checkout@v2
- uses: actions/setup-node@v4
- uses: actions/checkout@v4
- run: yarn install
- name: "yarn run gatsby build"
run: |
# The sed part of this command removes terminal escape codes.
OVERRIDE_NODE_ENV=development yarn run gatsby build 2> >(tee /dev/stdout | sed $'s/\e[^a-z]*[a-z]//g' > err.log)
- run: |
! grep ^ err.log
NODE_ENV=development yarn run gatsby build
- name: "Dirty check"
run: |
git add .
Expand Down
1 change: 1 addition & 0 deletions .node-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v20.12.2
25 changes: 6 additions & 19 deletions DEVELOPING.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,6 @@
# How to hack on this

## Releasing Docs for new Telepresence Versions
If you are only making changes to the `docs/` directory and those changes
aren't ready to go out immediately (for example, if they are for a future
telepresence release), please make those changes in the
[telepresence repository](https://github.com/telepresenceio/telepresence).

If you are making changes to more than the `docs/` and those changes are
for a future release, merge those changes into a branch `rel/x.y.z`.

When it is time to do a telepresence release, the docs will be pushed to
the [docs repo](https://github.com/telepresenceio/docs). From there, you can
create (or checkout if it already exists) a `rel/x.y.z` branch on this repo
and run `make pull-docs`. Once you merge that PR, the website will update
with the docs for the new release.

## Local development quickstart

Expand All @@ -29,10 +16,11 @@ Commands of interest:
yarn install # Install dependencies in to ./node_modules/

# Development
export NODE_OPTIONS=--openssl-legacy-provider
yarn run gatsby develop # Serve a hot-reloading development-build at http://localhost:8000/
yarn run gatsby repl # Run a Node.js REPL in the Gatsby environment
yarn run eslint . # Run the linter
make pull-docs # Update ./docs/ from ambassador-docs.git
make pull-docs # Update ./docs/ from telepresenceio/telepresence.git

# Production or production-like
yarn run gatsby build # Build a production-build, writing it to ./public/
Expand Down Expand Up @@ -191,11 +179,10 @@ So we should upgrade Gatsby and associated plugins, and then turn

The docs-build machinery in of `package.json`, `gatsby-config.js`,
`gatsby-node.js`, `src/assets/` and `src/components/` seem obviously
want be a separate reusable module, so that these things don't need to
be manually kept in-sync between getambassador.io, telepresence.io,
and emissaryingress.io. This seems to be mostly obvious an trival to
do... except for I can't figure how to handle
`src/templates/doc-page.js` to where it's sufficiently
want to be a separate reusable module, so that these things don't need to
be manually kept in-sync between telepresence.io, and telepresence.
This seems to be mostly obvious an trival to do... except for I can't
figure how to handle `src/templates/doc-page.js` to where it's sufficiently
parametarized/pluggable, or a way to make it possible to plug in the
site-specific one.

Expand Down
55 changes: 19 additions & 36 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,41 +1,24 @@
define nl


endef

subtree-preflight:
@if ! grep -q -e 'has_been_added' $$(PATH=$$(git --exec-path):$$PATH which git-subtree 2>/dev/null) /dev/null; then \
printf '$(RED)Please upgrade your git-subtree:$(END)\n'; \
printf '$(BLD) sudo curl -fL https://raw.githubusercontent.com/LukeShu/git/lukeshu/next/2021-05-15/contrib/subtree/git-subtree.sh -o $$(git --exec-path)/git-subtree && sudo chmod 755 $$(git --exec-path)/git-subtree$(END)\n'; \
false; \
else \
printf '$(GRN)git-subtree OK$(END)\n'; \
# Ensure that the telepresence remote is up-to-date.
telepresence-remote:
@if [ "$$(git remote | grep -E '^telepresence$$')" = 'telepresence' ]; then\
git remote update telepresence;\
else\
git remote add -f telepresence git@github.com:telepresenceio/telepresence.git;\
fi
git gc
.PHONY: subtree-preflight
.PHONY: telepresence-remote

PULL_PREFIX ?=
PUSH_PREFIX ?= $(USER)/from-telepresence.io-$(shell date +%Y-%m-%d)/
# MATCH_TAGS is the regexp matching the tags that we expect will have docs.
MATCH_TAGS ?= ^v2\.[2-9][0-9]+\.[0-9]+(-(rc|test)\.[0-9]+)$$

dir2branch = $(patsubst docs/%,release/%,$(subst pre-release,v2,$1))
# EXCLUDE_TAGS is used when we want to exclude some of the matching tags from the telepresence repository
EXCLUDE_TAGS ?=

# Used when syncing from telepresenceio since that repo doesn't
# have docs for v1.
EXCLUDE_DIR ?= ""
pull-docs: ## Update ./docs from https://github.com/telepresenceio/docs
pull-docs: subtree-preflight
$(foreach subdir,$(shell find docs -mindepth 1 -maxdepth 1 -type d -not -name $(EXCLUDE_DIR)|sort -V),\
git subtree pull --squash --prefix=$(subdir) https://github.com/telepresenceio/docs $(PULL_PREFIX)$(call dir2branch,$(subdir))$(nl))
# Update the docs at docs/v<major>.<minor> from the found tags.
pull-docs:
$(foreach release,$(shell git tag -l | grep -E '$(MATCH_TAGS)' | (test -n '$(EXCLUDE_TAGS)' && grep -vE '$(EXCLUDE_TAGS)' || cat) | sort -V),\
dir=$$(expr '$(release)' : '\(v[0-9]\.[0-9][0-9]*\)');\
echo $$dir;\
rm -rf docs/$$dir;\
git add docs;\
git read-tree --prefix docs/$$dir -u $(release):docs)
.PHONY: pull-docs

PUSH_BRANCH ?= $(USER)/from-telepresence.io-$(shell date +%Y-%m-%d)
push-docs: ## Publish ./ambassador to https://github.com/telepresenceio/docs
push-docs: subtree-preflight
@PS4=; set -x; { \
git remote add --no-tags remote-docs https://github.com/telepresenceio/docs && \
git remote set-url --push remote-docs git@github.com:telepresenceio/docs && \
:; } || true
git fetch --prune remote-docs
$(foreach subdir,$(shell find docs -mindepth 1 -maxdepth 1 -type d|sort -V),\
git subtree push --rejoin --squash --prefix=$(subdir) remote-docs $(PUSH_PREFIX)$(call dir2branch,$(subdir))$(nl))
.PHONY: push-docs
6 changes: 3 additions & 3 deletions bin/serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function matchesRedirect(forcefulOnly, requestURL, redirect) {

function doRedirect(requestURL, response, redirect) {
let location = redirect.to;
if (!url.parse(location).search) {
if (!new URL(location).search) {
location += (requestURL.search||'');
}
response.writeHead(redirect.status, {
Expand All @@ -54,8 +54,8 @@ function doRedirect(requestURL, response, redirect) {

server.on('request', async (request, response) => {
console.log(request.method, request.url);
const requestURL = url.parse(url.resolve('/', request.url));
if (requestURL.protocol || requestURL.slashes || requestURL.host) {
const requestURL = new URL(url.resolve('/', request.url));
if (requestURL.protocol || requestURL.host) {
response.writeHead(400);
response.end('Bad request URL');
}
Expand Down
15 changes: 4 additions & 11 deletions docs-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ module.exports = {
return '/docs/' + (node.relativePath
.replaceAll(path.sep, path.posix.sep)
.replace(/\/index\.md$/, '/')
.replace(/\.md$/, '/')
.replace(/releaseNotes\.yml$/, 'release-notes/'));
.replace(/\.md$/, '/'));
},

docrootURL: function(node) {
Expand All @@ -40,21 +39,15 @@ module.exports = {
},

canonicalURL: function(node) {
const urlpath = this.urlpath(node);
const version = urlpath.split(path.posix.sep)[2];
if (version === "v1") {
// v1 docs aren't on getambassador.io
return urlpath;
}
const relpath = urlpath.split(path.posix.sep).slice(3).join(path.posix.sep);
const relpath = this.urlpath(node).split(path.posix.sep).slice(3).join(path.posix.sep);
return `https://www.getambassador.io/docs/telepresence/latest/${relpath}`;
},

githubURL: function(node) {
const gitpath = 'docs/' + (node.relativePath
.replace(/^latest/,'v2.5')
.replace(/^latest\//,'')
.replaceAll(path.sep, path.posix.sep));
return `https://github.com/telepresenceio/telepresence.io/blob/master/${gitpath}`;
return `https://github.com/telepresenceio/telepresence/blob/release/v2/${gitpath}`;
},

// Don't show reading time for Telepresence.
Expand Down
83 changes: 0 additions & 83 deletions docs/2.14/doc-links.yml

This file was deleted.

61 changes: 0 additions & 61 deletions docs/2.14/quick-start/TelepresenceQuickStartLanding.js

This file was deleted.

Loading
Loading