-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: import and update documentation from PWA Guide (#125)
- Loading branch information
Showing
61 changed files
with
4,113 additions
and
663 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,61 @@ | ||
# Documentation | ||
<!-- | ||
kb_concepts | ||
kb_pwa | ||
kb_everyone | ||
kb_sync_latest_only | ||
--> | ||
|
||
## [Project Structure](./project-structure.md) | ||
# Documentation Overview | ||
|
||
## [State Management](./state-management.md) | ||
## Developers | ||
|
||
## [Customizations](./customizations.md) | ||
- [Getting Started](./guides/getting-started.md) | ||
|
||
## [Migrations](./migrations.md) | ||
### Architecture | ||
|
||
## [Search Engine Optimization](./search-engine-optimization.md) | ||
- [Concept - Software Architecture](./concepts/software-architecture.md) | ||
- [Concept - Project Structure](./concepts/project-structure.md) | ||
- [Concept - State Management](./concepts/state-management.md) | ||
- [Guide - State Management](./guides/state-management.md) | ||
- [Concept - CMS Integration](./concepts/cms-integration.md) | ||
- [Concept - Configuration](./concepts/configuration.md) | ||
- [Guide - Propagating Environment Variables](./guides/propagating-environment-variables.md) | ||
- [Concept - Localization](./concepts/localization.md) | ||
- [Concept - SEO](./concepts/search-engine-optimization.md) | ||
- [Guide - Forms](./guides/forms.md) | ||
|
||
### Developing | ||
|
||
- [Guide - Development Environment](./guides/development.md) | ||
- [Concept - Styling](./concepts/styling-behavior.md) | ||
- [Concept - Testing](./concepts/testing.md) | ||
- [Guide - Testing with Jest](./guides/testing-jest.md) | ||
- [Guide - Testing with Cypress](./guides/testing-cypress.md) | ||
- [Guide - Code Documentation](./guides/code-documentation.md) | ||
- [Guide - Angular Component Development](./guides/angular-component-development.md) | ||
- [Guide - Angular Change Detection](./guides/angular-change-detection.md) | ||
- [Guide - Data Handling with Mappers](./guides/data-handling-with-mappers.md) | ||
|
||
### Customization | ||
|
||
- [Guide - Customizations](./guides/customizations.md) | ||
- [Guide - Multiple Themes](./guides/multiple-themes.md) | ||
- [Guide - Migration](./guides/migrations.md) | ||
- [Concept - URL Rewriting](./concepts/url-rewriting.md) | ||
- [Guide - Mocking REST API Calls](./guides/mocking-rest-calls.md) | ||
|
||
## Operations | ||
|
||
### Setup | ||
|
||
- [Concept - Deployment Scenarios](./concepts/deployment-scenarios.md) | ||
- [Guide - SSR Parameters](./guides/ssr-startup.md) | ||
- [Concept - Hybrid Approach](./concepts/hybrid-approach.md) | ||
- [Guide - Hybrid Approach and ICM URL Rewriting](./guides/hybrid-approach-icm-url-rewriting.md) | ||
- [Guide - CI](./guides/continuous-integration.md) | ||
- [Guide - Google Tag Manager](./guides/google-tag-manager.md) | ||
|
||
### Monitoring | ||
|
||
- [Concept - Logging](./concepts/logging.md) | ||
- [Guide - Client-Side Error Monitoring with Sentry](./guides/sentry-error-monitoring.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const async = require('async'); | ||
const { promisify } = require('util'); | ||
const glob = promisify(require('glob')); | ||
|
||
async function checkExternalLinkError(link) { | ||
console.log('check', link); | ||
const client = link.startsWith('https') ? require('https') : require('http'); | ||
return new Promise(resolve => { | ||
const req = client.request(link, res => { | ||
isError = res.statusCode >= 400; | ||
if (isError) { | ||
console.warn('found dead link to', link); | ||
} | ||
resolve(isError); | ||
}); | ||
|
||
req.on('error', () => { | ||
console.warn('found dead link to', link); | ||
resolve(true); | ||
}); | ||
req.end(); | ||
}); | ||
} | ||
|
||
function sleep(milliseconds) { | ||
return new Promise(resolve => setTimeout(resolve, milliseconds)); | ||
} | ||
|
||
function getLineInfoOfString(data, str) { | ||
var perLine = data.split('\n'); | ||
for (let line = 0; line < perLine.length; line++) { | ||
const index = perLine[line].indexOf(str); | ||
if (index > 0) { | ||
return ':' + (line + 1) + ':' + (index + 1); | ||
} | ||
} | ||
return ''; | ||
} | ||
|
||
glob('**/*.md') | ||
.then(files => { | ||
const externalLinks = []; | ||
let isError = false; | ||
|
||
files | ||
.filter(file => !file.includes('node_modules')) | ||
.forEach(file => { | ||
const content = fs.readFileSync(file, { encoding: 'utf-8' }); | ||
const match = content.match(/\[.*?\](\(|:\s+)[^\s]*\)?/g); | ||
if (match) { | ||
match.forEach(link => { | ||
const linkTo = /\](\(<?|:\s+)(.*?)(>?\)|$|#)/.exec(link)[2]; | ||
|
||
if (linkTo) { | ||
// link is not document-internal | ||
if (linkTo.startsWith('http')) { | ||
externalLinks.push(linkTo); | ||
} else { | ||
const normalized = path.normalize(path.join(path.dirname(file), linkTo)); | ||
if (!fs.existsSync(normalized)) { | ||
console.warn(file + getLineInfoOfString(content, linkTo) + ': found dead link to "' + linkTo + '"'); | ||
isError = true; | ||
} | ||
} | ||
} | ||
}); | ||
} | ||
}); | ||
if (isError) { | ||
throw new Error('found dead internal links'); | ||
} | ||
return externalLinks; | ||
}) | ||
.then(externalLinks => { | ||
if (process.argv.length > 2 && process.argv[2] === 'fast') { | ||
console.warn('skipping external link check'); | ||
return; | ||
} | ||
|
||
const filtered = externalLinks | ||
.map(link => link.replace(/\/$/, '')) | ||
.filter((val, idx, arr) => arr.indexOf(val) === idx) | ||
.filter( | ||
link => | ||
!link.includes('github.com') && | ||
!link.includes('repository.intershop.de') && | ||
!link.includes('support.intershop.com') && | ||
!link.includes('github.com/intershop/intershop-pwa/commit') | ||
) | ||
.sort(); | ||
|
||
async.eachSeries( | ||
filtered, | ||
async link => { | ||
const isError = await checkExternalLinkError(link); | ||
if (isError) throw new Error('found dead external link to', link); | ||
await sleep(1000); | ||
}, | ||
err => { | ||
if (err) throw err; | ||
} | ||
); | ||
}) | ||
.catch(err => { | ||
console.error(err.message); | ||
process.exit(1); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const glob = require('glob'); | ||
|
||
const overviewContent = fs.readFileSync('docs/README.md', { encoding: 'utf-8' }); | ||
const match = overviewContent.match(/\[.*?\](\(|:\s+)[^\s]*\)?/g); | ||
const links = []; | ||
|
||
if (match) { | ||
match.forEach(link => { | ||
const linkTo = /\](\(<?|:\s+)(.*?)(>?\)|$|#)/.exec(link)[2]; | ||
|
||
if (linkTo) { | ||
// link is not document-internal | ||
if (!linkTo.startsWith('http')) { | ||
const basename = path.normalize(path.join(process.cwd(), 'docs', linkTo)); | ||
links.push(basename); | ||
} | ||
} | ||
}); | ||
} | ||
|
||
const files = glob.sync('docs/*/*.md'); | ||
let isError = false; | ||
|
||
files.forEach(file => { | ||
const fullPath = path.join(process.cwd(), file); | ||
// console.log('######'); | ||
// console.log(files); | ||
// console.log(fullPath); | ||
if (!links.includes(fullPath)) { | ||
console.warn('document not linked in overview docs/README.md: .' + file.substr(4)); | ||
isError = true; | ||
} | ||
}); | ||
|
||
if (isError) { | ||
process.exit(1); | ||
} |
Oops, something went wrong.