Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,20 +121,20 @@ jobs:
- name: Clean cache on stage
if: needs.set-state.outputs.clean_cache == 'true' && needs.set-state.outputs.deploy_stage == 'true'
run: |
bash .github/scripts/process-mds.sh cache stage ${{ needs.set-state.outputs.branch_short_ref }} "${{ needs.set-state.outputs.path_prefix }}"
bash .github/scripts/process-mds.sh cache stage ${{ needs.set-state.outputs.branch_short_ref }} "${{ needs.set-state.outputs.path_prefix }}"

- name: Clean cache on prod
if: needs.set-state.outputs.clean_cache == 'true' && needs.set-state.outputs.deploy_prod == 'true'
run: |
bash .github/scripts/process-mds.sh cache prod ${{ needs.set-state.outputs.branch_short_ref }} "${{ needs.set-state.outputs.path_prefix }}"
bash .github/scripts/process-mds.sh cache prod ${{ needs.set-state.outputs.branch_short_ref }} "${{ needs.set-state.outputs.path_prefix }}"

- name: Deploy to stage
if: needs.set-state.outputs.deploy_stage == 'true'
run: |
bash .github/scripts/process-mds.sh preview stage ${{ needs.set-state.outputs.branch_short_ref }} "${{ needs.set-state.outputs.path_prefix }}"
bash .github/scripts/process-mds.sh preview stage ${{ needs.set-state.outputs.branch_short_ref }} "${{ needs.set-state.outputs.path_prefix }}"

- name: Deploy to prod
if: needs.set-state.outputs.deploy_prod == 'true'
run: |
bash .github/scripts/process-mds.sh preview prod ${{ needs.set-state.outputs.branch_short_ref }} "${{ needs.set-state.outputs.path_prefix }}"
bash .github/scripts/process-mds.sh live prod ${{ needs.set-state.outputs.branch_short_ref }} "${{ needs.set-state.outputs.path_prefix }}"
run: |
bash .github/scripts/process-mds.sh preview prod ${{ needs.set-state.outputs.branch_short_ref }} "${{ needs.set-state.outputs.path_prefix }}"
bash .github/scripts/process-mds.sh live prod ${{ needs.set-state.outputs.branch_short_ref }} "${{ needs.set-state.outputs.path_prefix }}"
14 changes: 2 additions & 12 deletions buildRedirections.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const path = require('path');
const fs = require('node:fs');
const { pathPrefix } = require('./gatsby-config.js');
const { globSync }= require('glob');
const { writeRedirectionsFile } = require('./scriptUtils.js');

try {
if(!pathPrefix) {
Expand Down Expand Up @@ -39,17 +39,7 @@ try {
}
});

let redirectionsData =
{
"total" : data.length,
"offset": 0,
"limit": data.length,
"data" : data,
":type": "sheet"
};

let redirectionsFilePath = path.resolve(__dirname + '/src/pages/redirects.json');
fs.writeFileSync(redirectionsFilePath, JSON.stringify(redirectionsData));
writeRedirectionsFile(data);

} catch (err) {
console.error(err);
Expand Down
66 changes: 66 additions & 0 deletions normalizeLinks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
const path = require('path');
const fs = require('node:fs');
const matchAll = require('string.prototype.matchall');
const {
getMarkdownFiles,
replaceLinksInFile,
getFindPatternForMarkdownFiles: getFindPattern,
getReplacePatternForMarkdownFiles: getReplacePattern,
} = require('./scriptUtils.js');

function normalizeLinksInMarkdownFile(file, files) {
const relativeToDir = path.dirname(file);
const relativeFiles = files.map(file => path.relative(relativeToDir, file));
const linkMap = new Map();

const linkPattern = getFindPattern('[^)#]*');
let data = fs.readFileSync(file, 'utf8');
const links = matchAll(data, new RegExp(linkPattern, "gm"));
[...links].forEach(link => {
const optionalPrefix = link[2] ?? '';
const from = link[3] ?? '';
let to = from;

// ensure link includes file name and extension
if(to.endsWith('/') || optionalPrefix.endsWith('/') && !to) {
to = `${to}index.md`
}
if(!to.endsWith('.md') && to) {
to = `${to}.md`;
}

to = to.replaceAll('/', path.sep);

// ensure simplest relative path
// this removes trailing slash, so need to do this after the file name and extension checks above
const absolute = path.resolve(relativeToDir, to);
const relative = path.relative(relativeToDir, absolute);
to = relative;

// ensure the link we constructed above exists
const toExists = relativeFiles.find(file => to === file);

to = to.replaceAll(path.sep, '/');

if(to !== from && toExists) {
linkMap.set(from, to);
}
})

replaceLinksInFile({
file,
linkMap,
getFindPattern,
getReplacePattern,
});
}

try {
const files = getMarkdownFiles();
files.forEach(file => {
normalizeLinksInMarkdownFile(file, files);
});

} catch (err) {
console.error(err);
}
13 changes: 7 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
{
"private": true,
"name": "adobe-dev-console",
"name": "dev-site-documentation-template",
"version": "1.0.0",
"license": "Apache-2.0",
"repository": {
"type": "git",
"url": "https://github.com/AdobeDocs/adobe-dev-console"
"url": "https://github.com/AdobeDocs/dev-site-documentation-template"
},
"author": {
"name": "Stephan Ringel",
"url": "https://github.com/icaraps"
},
"dependencies": {
"@adobe/gatsby-theme-aio": "^4.14.18",
"@adobe/gatsby-theme-aio": "^4.14.6",
"gatsby": "4.22.0",
"react": "^17.0.2",
"react-dom": "^17.0.2"
Expand All @@ -27,20 +27,21 @@
"dev": "gatsby develop",
"dev:https": "gatsby develop --https --host localhost.corp.adobe.com --port 9000",
"build": "gatsby build",
"build:incremental": "GATSBY_EXPERIMENTAL_PAGE_BUILD_ON_DATA_CHANGES=true gatsby build --log-pages",
"serve": "gatsby serve",
"clean": "gatsby clean",
"test:links": "remark src/pages --quiet --frail",
"lint": "docker run --rm -e RUN_LOCAL=true --env-file '.github/super-linter.env' -v \"$PWD\":/tmp/lint github/super-linter:slim-v4.10.1",
"buildNavigation": "node buildNavigation.js",
"buildRedirections": "node buildRedirections.js"
"buildRedirections": "node buildRedirections.js",
"renameFiles": "node renameFiles.js",
"normalizeLinks": "node normalizeLinks.js"
},
"remarkConfig": {
"plugins": [
"remark-validate-links"
]
},
"packageManager": "[email protected].2",
"packageManager": "[email protected].1",
"devDependencies": {
"glob": "11.0.0",
"remark-cli": "^11.0.0",
Expand Down
142 changes: 142 additions & 0 deletions renameFiles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
const path = require('path');
const fs = require('node:fs');
const { pathPrefix } = require('./gatsby-config.js');
const {
readRedirectionsFile,
writeRedirectionsFile,
getRedirectionsFilePath,
getMarkdownFiles,
getFindPatternForMarkdownFiles,
getReplacePatternForMarkdownFiles,
replaceLinksInFile
} = require('./scriptUtils.js');

function toKebabCase(str) {
const isScreamingSnakeCase = new RegExp(/^[A-Z0-9_]*$/gm).test(str);
str = isScreamingSnakeCase ? str.toLowerCase() : str;
return str
.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g)
.map(x => x.toLowerCase())
.join('-');
}

function toEdsCase(str) {
const isValid = Boolean((/^([a-z0-9-]*)$/.test(str)));
return isValid ? str : toKebabCase(str);
}

function toUrl(file, renameBaseWithoutExt = name => name) {
const base = path.basename(file);
const ext = path.extname(file);
const end = file.length - base.length;
const baseWithoutExt = base.substring(0, base.length - ext.length);
const newBaseWithoutExt = renameBaseWithoutExt(baseWithoutExt);
return `${file.substring(0, end)}${newBaseWithoutExt}`
}

function renameFile(file, renameBaseWithoutExt) {
const url = toUrl(file, renameBaseWithoutExt);
const ext = path.extname(file);
return `${url}${ext}`
}

function getFileMap(files) {
const map = new Map();
files.forEach(from => {
const to = renameFile(from, toEdsCase)
if(to !== from) {
map.set(from, to)
}
});
return map;
}

function getLinkMap(fileMap, relativeToDir) {
const linkMap = new Map();
fileMap.forEach((toFile, fromFile) => {
let fromRelFile = path.relative(relativeToDir, fromFile);
fromRelFile = fromRelFile.replaceAll(path.sep, '/');

let toRelFile = path.relative(relativeToDir, toFile);
toRelFile = toRelFile.replaceAll(path.sep, '/');

linkMap.set(fromRelFile, toRelFile);
});
return linkMap;
}

function renameLinksInMarkdownFile(fileMap, file) {
const dir = path.dirname(file);
replaceLinksInFile({
file,
linkMap: getLinkMap(fileMap, dir),
getFindPattern: getFindPatternForMarkdownFiles,
getReplacePattern: getReplacePatternForMarkdownFiles,
});
}

function renameLinksInRedirectsFile(fileMap) {
const file = getRedirectionsFilePath();
const dir = path.dirname(file);
replaceLinksInFile({
file,
linkMap: getLinkMap(fileMap, dir),
getFindPattern: (from) => `(['"]?)(Source|Destination)(['"]?\\s*:\\s*['"])(${pathPrefix}${toUrl(from)})(/?)(#[^'"]*)?(['"])`,
getReplacePattern: (to) => `$1$2$3${pathPrefix}${toUrl(to)}$5$6$7`,
});
}

function renameLinksInGatsbyConfigFile(fileMap, file) {
const dir = path.join('src', 'pages');
replaceLinksInFile({
file,
linkMap: getLinkMap(fileMap, dir),
getFindPattern: (from) => `(['"]?path['"]?\\s*:\\s*['"])(/|./)?(${from})(#[^'"]*)?(['"])`,
getReplacePattern: (to) => `$1$2${to}$4$5`,
});
}

function appendRedirects(fileMap) {
const file = getRedirectionsFilePath();
const dir = path.dirname(file);
const linkMap = getLinkMap(fileMap, dir);
const newData = [];
linkMap.forEach((to, from) => {
newData.push({
Source: `${pathPrefix}${toUrl(from)}`,
Destination: `${pathPrefix}${toUrl(to)}`,
})
});
const currData = readRedirectionsFile();
const data = [...currData, ...newData];
writeRedirectionsFile(data);
}

function renameFiles(map) {
map.forEach((to, from) => {
fs.renameSync(from, to);
});
}

try {
const markdownFiles = getMarkdownFiles();
const fileMap = getFileMap(markdownFiles);
markdownFiles.forEach(file => {
renameLinksInMarkdownFile(fileMap, file);
});
renameFiles(fileMap);

const redirectsFile = getRedirectionsFilePath();
if(fs.existsSync(redirectsFile)) {
renameLinksInRedirectsFile(fileMap);
appendRedirects(fileMap);
}

const gatsbyConfigFile = 'gatsby-config.js';
if(fs.existsSync(gatsbyConfigFile)) {
renameLinksInGatsbyConfigFile(fileMap, gatsbyConfigFile);
}

} catch (err) {
console.error(err);
}
55 changes: 55 additions & 0 deletions scriptUtils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
const path = require('path');
const fs = require('node:fs');
const { globSync }= require('glob');

function getRedirectionsFilePath() {
const redirectionsFilePath = path.join(__dirname, 'src', 'pages', 'redirects.json');
return path.resolve(redirectionsFilePath);
}

function readRedirectionsFile() {
const redirectionsFilePath = getRedirectionsFilePath();
return JSON.parse(fs.readFileSync(redirectionsFilePath)).data;
}

function writeRedirectionsFile(data) {
let redirectionsData =
{
"total" : data.length,
"offset": 0,
"limit": data.length,
"data" : data,
":type": "sheet"
};

let redirectionsFilePath = getRedirectionsFilePath();
fs.writeFileSync(redirectionsFilePath, JSON.stringify(redirectionsData));
}

function getMarkdownFiles() {
return globSync(__dirname + '/src/pages/**/*.md')
.map(f => path.resolve(f));
}

const getFindPatternForMarkdownFiles = (from) => `(\\[[^\\]]*]\\()(/|./)?(${from})(#[^\\()]*)?(\\))`;
const getReplacePatternForMarkdownFiles = (to) => `$1$2${to}$4$5`;

function replaceLinksInFile({ file, linkMap, getFindPattern, getReplacePattern }) {
let data = fs.readFileSync(file, 'utf8');
linkMap.forEach((to, from) => {
const find = getFindPattern(from);
const replace = getReplacePattern(to);
data = data.replaceAll(new RegExp(find, "gm"), replace);
});
fs.writeFileSync(file, data, 'utf-8');
}

module.exports = {
getRedirectionsFilePath,
readRedirectionsFile,
writeRedirectionsFile,
getMarkdownFiles,
getFindPatternForMarkdownFiles,
getReplacePatternForMarkdownFiles,
replaceLinksInFile
};
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Read our OAuth Server-to-server credential implementation guide -

<InlineAlert slots="text"/>

The Service Account (JWT) credentials have been deprecated in favor of the OAuth Server-to-Server credentials. Your applications using the Service Account (JWT) credentials will stop working after Jun 30, 2025. You must migrate to the new credential by **Jun 30, 2025**, to ensure your application continues functioning. [Learn more](../ServerToServerAuthentication/migration.md).
The Service Account (JWT) credentials have been deprecated in favor of the OAuth Server-to-Server credentials. Your applications using the Service Account (JWT) credentials will stop working after Jun 30, 2025. You must migrate to the new credential by **Jun 30, 2025**, to ensure your application continues functioning. [Learn more](migration.md).

Service Account (JWT) credentials rely on the JWT token exchange mechanism to generate access tokens. This credential's details include two secrets a `client_secret` and a `private.key` (part of a public certificate private key pair).

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# User Authentication Implementation Guide

The following guide goes over finer implementation details for user authentication credentials. At the end of this guide is a list of recommended industry-standard OAuth2 libraries. Before proceeding, we recommend you familiarize yourself with the 3-legged OAuth flow in our [user authentication guide](../UserAuthentication/index.md).
The following guide goes over finer implementation details for user authentication credentials. At the end of this guide is a list of recommended industry-standard OAuth2 libraries. Before proceeding, we recommend you familiarize yourself with the 3-legged OAuth flow in our [user authentication guide](index.md).

## User authentication credential types

Expand Down
2 changes: 1 addition & 1 deletion src/pages/guides/plugins/plugin-distribution.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This guide provides instructions for distributing a Plugin created in Adobe Developer Console.

For information on how to build a plugin, please being by reading the [plugin overview](../plugins/index.md).
For information on how to build a plugin, please being by reading the [plugin overview](index.md).

## Select plugin project

Expand Down
Loading