Merge branch 'master' of github.com:spotify/backstage into feat/backend-plugin

* 'master' of github.com:spotify/backstage:
  docs: clarify role of identity and SignInPage
  tests(register-component): update tests to use test-id for submit button
  feature(component-registration): allow SCM specification
  Fix identity typo
  Bump version of techdocs-core plugin in techdocs-container (#2539)
  TechDocs: adjust mkdocs extensions (#2516)
  comment to explain option
  Added toggled option for allowing longpath in windows through nodegit
  create-app: fix missing .gitignore file when scaffolded
This commit is contained in:
blam
2020-09-22 02:00:35 +02:00
13 changed files with 199 additions and 61 deletions
+7
View File
@@ -35,6 +35,13 @@ full list of providers, see the
### Identity - WIP
> NOTE: Identity management and the `SignInPage` in Backstage is NOT a method
> for blocking access for unauthorized users, that either requires additional
> backend implementation or a separate service like Google's Identity-Aware
> Proxy. The identity system only serves to provide a personalized experience
> and access to a Backstage Identity Token, which can be passed to backend
> plugins.
Identity management is still work in progress, but there are already a couple of
pieces in place that can be used.
@@ -1,4 +1,3 @@
# Logs
logs
*.log
@@ -31,4 +30,4 @@ dist-types
site
# Local configuration files
*.local.yaml
*.local.yaml
+1 -1
View File
@@ -18,7 +18,7 @@ FROM python:3.8-alpine
RUN apk update && apk --no-cache add gcc musl-dev openjdk11-jdk curl graphviz ttf-dejavu fontconfig
RUN curl -L http://sourceforge.net/projects/plantuml/files/plantuml.1.2020.16.jar/download > /opt/plantuml.jar
RUN pip install --upgrade pip && pip install mkdocs-techdocs-core==0.0.7
RUN pip install --upgrade pip && pip install mkdocs-techdocs-core==0.0.8
# Create script to call plantuml.jar from a location in path
@@ -3,10 +3,9 @@
!!! test
Testing somethin
Abbreviations:
Some text about MOCDOC
\*[MOCDOC]: Mock Documentation
This is a paragraph.
{: #test_id .test_class }
@@ -61,3 +60,40 @@ digraph G {
```
:bulb:
=== "JavaScript"
```javascript
import { test } from 'something';
const addThingToThing = (a, b) a + b;
```
=== "Java"
```java
public void function() {
test();
}
```
```java tab="java"
public void function() {
test();
}
```
```java tab="java 2"
public void function() {
test();
}
```
```javascript
import { test } from 'something';
const addThingToThing = (a, b) a + b;
```
<!-- prettier-ignore -->
*[MOCDOC]: Mock Documentation
@@ -48,8 +48,72 @@ python -m black src/
**Note:** This will write to all Python files in `src/` with the formatted code. If you would like to only check to see if it passes, simply append the `--check` flag.
## MkDocs plugins and extensions
The TechDocs Core MkDocs plugin comes with a set of extensions and plugins that mkdocs supports. Below you can find a list of all extensions and plugins that are included in the
TechDocs Core plugin:
Plugins:
- [search](https://www.mkdocs.org/user-guide/configuration/#search)
- [mkdocs-monorepo-plugin](https://github.com/spotify/mkdocs-monorepo-plugin)
Extensions:
- [admonition](https://squidfunk.github.io/mkdocs-material/reference/admonitions/#admonitions)
- [toc](https://python-markdown.github.io/extensions/toc/)
- [pymdown](https://facelessuser.github.io/pymdown-extensions/)
- caret
- critic
- details
- emoji
- superfences
- inlinehilite
- magiclink
- mark
- smartsymobls
- highlight
- extra
- tabbed
- tasklist
- tilde
- [markdown_inline_graphviz](https://pypi.org/project/markdown-inline-graphviz/)
- [plantuml_markdown](https://pypi.org/project/plantuml-markdown/)
## Changelog
### 0.0.8
- Superfences and Codehilite doesn't work very well together (squidfunk/mkdocs-material#1604) so therefore the codehilite extension is replaced by pymdownx.highlight
* Uses pymdownx extensions v.7.1 instead of 8.0.0 to allow legacy_tab_classes config. This makes the techdocs core plugin compatible with the usage of tabs for grouping markdown with the following syntax:
````
```java tab="java 2"
public void function() {
....
}
```
````
as well as the new
````
=== "Java"
```java
public void function() {
....
}
```
````
The pymdownx extension will be bumped too 8.0.0 in the near future.
- pymdownx.tabbed is added to support tabs to group markdown content, such as codeblocks.
- "PyMdown Extensions includes three extensions that are meant to replace their counterpart in the default Python Markdown extensions." Therefore some extensions has been taken away in this version that comes by default from pymdownx.extra which is added now (https://facelessuser.github.io/pymdown-extensions/usage_notes/#incompatible-extensions)
### 0.0.7
- Fix an issue with configuration of emoji support
@@ -7,7 +7,7 @@ mkdocs-monorepo-plugin==0.4.5
plantuml-markdown==3.1.2
markdown_inline_graphviz_extension==1.1
pygments==2.6.1
pymdown-extensions==8.0.0
pymdown-extensions==7.1
# The linter using for Python
# Note: This requires Python 3.6+ to run, but can format Python 2 code too.
@@ -17,38 +17,34 @@ from setuptools import setup, find_packages
setup(
name='mkdocs-techdocs-core',
version='0.0.7',
description='A Mkdocs package that contains TechDocs defaults',
long_description='',
keywords='mkdocs',
url='https://github.com/spotify/backstage',
author='TechDocs Core',
author_email='pulp-fiction@spotify.com',
license='Apache-2.0',
python_requires='>=3.7',
name="mkdocs-techdocs-core",
version="0.0.8",
description="A Mkdocs package that contains TechDocs defaults",
long_description="",
keywords="mkdocs",
url="https://github.com/spotify/backstage",
author="TechDocs Core",
author_email="pulp-fiction@spotify.com",
license="Apache-2.0",
python_requires=">=3.7",
install_requires=[
'mkdocs>=1.1.2',
'mkdocs-material==5.3.2',
'mkdocs-monorepo-plugin==0.4.5',
'plantuml-markdown==3.1.2',
'markdown_inline_graphviz_extension==1.1',
'pygments==2.6.1',
'pymdown-extensions==8.0.0'
"mkdocs>=1.1.2",
"mkdocs-material==5.3.2",
"mkdocs-monorepo-plugin==0.4.5",
"plantuml-markdown==3.1.2",
"markdown_inline_graphviz_extension==1.1",
"pygments==2.6.1",
"pymdown-extensions==7.1",
],
classifiers=[
'Development Status :: 1 - Planning',
'Intended Audience :: Developers',
'Intended Audience :: Information Technology',
'License :: OSI Approved :: Apache Software License',
'Programming Language :: Python',
'Programming Language :: Python :: 3 :: Only',
'Programming Language :: Python :: 3.7'
"Development Status :: 1 - Planning",
"Intended Audience :: Developers",
"Intended Audience :: Information Technology",
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.7",
],
packages=find_packages(),
entry_points={
'mkdocs.plugins': [
'techdocs-core = src.core:TechDocsCore'
]
}
entry_points={"mkdocs.plugins": ["techdocs-core = src.core:TechDocsCore"]},
)
@@ -14,7 +14,7 @@
* limitations under the License.
"""
from mkdocs.plugins import BasePlugin, PluginCollection
from mkdocs.plugins import BasePlugin
from mkdocs.theme import Theme
from mkdocs.contrib.search import SearchPlugin
from mkdocs_monorepo_plugin.plugin import MonorepoPlugin
@@ -54,25 +54,11 @@ class TechDocsCore(BasePlugin):
# Markdown Extensions
config["markdown_extensions"].append("admonition")
config["markdown_extensions"].append("abbr")
config["markdown_extensions"].append("attr_list")
config["markdown_extensions"].append("def_list")
config["markdown_extensions"].append("codehilite")
config["mdx_configs"]["codehilite"] = {
"linenums": True,
"guess_lang": False,
"pygments_style": "friendly",
}
config["markdown_extensions"].append("toc")
config["mdx_configs"]["toc"] = {
"permalink": True,
}
config["markdown_extensions"].append("footnotes")
config["markdown_extensions"].append("markdown.extensions.tables")
config["markdown_extensions"].append("pymdownx.betterem")
config["mdx_configs"]["pymdownx.betterem"] = {
"smart_enable": "all",
}
config["markdown_extensions"].append("pymdownx.caret")
config["markdown_extensions"].append("pymdownx.critic")
config["markdown_extensions"].append("pymdownx.details")
@@ -83,6 +69,18 @@ class TechDocsCore(BasePlugin):
config["markdown_extensions"].append("pymdownx.mark")
config["markdown_extensions"].append("pymdownx.smartsymbols")
config["markdown_extensions"].append("pymdownx.superfences")
config["mdx_configs"]["pymdownx.superfences"] = {
"legacy_tab_classes": True,
}
config["markdown_extensions"].append("pymdownx.highlight")
config["mdx_configs"]["pymdownx.highlight"] = {
"linenums": True,
}
config["markdown_extensions"].append("pymdownx.extra")
config["mdx_configs"]["pymdownx.betterem"] = {
"smart_enable": "all",
}
config["markdown_extensions"].append("pymdownx.tabbed")
config["markdown_extensions"].append("pymdownx.tasklist")
config["mdx_configs"]["pymdownx.tasklist"] = {
"custom_checkbox": True,
@@ -58,7 +58,7 @@ describe('Catalog Filter', () => {
] as Entity[]),
};
const indentityApi: Partial<IdentityApi> = {
const identityApi: Partial<IdentityApi> = {
getUserId: () => 'tools@example.com',
};
@@ -68,7 +68,7 @@ describe('Catalog Filter', () => {
<ApiProvider
apis={ApiRegistry.from([
[catalogApiRef, catalogApi],
[identityApiRef, indentityApi],
[identityApiRef, identityApi],
[storageApiRef, MockStorageApi.create()],
])}
>
@@ -41,7 +41,9 @@ describe('RegisterComponentForm', () => {
),
).toBeInTheDocument();
const submit = (await rendered.getByRole('button')) as HTMLButtonElement;
const submit = (await rendered.getByTestId(
'registerComponentFormSubmit',
)) as HTMLButtonElement;
expect(submit.disabled).toBeTruthy();
});
@@ -54,7 +56,9 @@ describe('RegisterComponentForm', () => {
target: { value: 'https://example.com/blob/master/component.yaml' },
});
});
const submit = (await rendered.getByRole('button')) as HTMLButtonElement;
const submit = (await rendered.getByTestId(
'registerComponentFormSubmit',
)) as HTMLButtonElement;
expect(submit.disabled).toBeFalsy();
});
@@ -21,10 +21,13 @@ import {
FormHelperText,
LinearProgress,
TextField,
Select,
MenuItem,
InputLabel,
} from '@material-ui/core';
import { makeStyles } from '@material-ui/core/styles';
import React, { FC } from 'react';
import { useForm } from 'react-hook-form';
import { useForm, Controller } from 'react-hook-form';
import { ComponentIdValidators } from '../../util/validate';
const useStyles = makeStyles<BackstageTheme>(theme => ({
@@ -44,7 +47,7 @@ export type Props = {
};
const RegisterComponentForm: FC<Props> = ({ onSubmit, submitting }) => {
const { register, handleSubmit, errors, formState } = useForm({
const { control, register, handleSubmit, errors, formState } = useForm({
mode: 'onChange',
});
const classes = useStyles();
@@ -84,8 +87,33 @@ const RegisterComponentForm: FC<Props> = ({ onSubmit, submitting }) => {
</FormHelperText>
)}
</FormControl>
<FormControl variant="outlined">
<InputLabel id="scmLabel">SCM Detection</InputLabel>
<Controller
control={control}
name="scmType"
defaultValue="AUTO"
render={({ onChange, onBlur, value }) => (
<Select
labelId="scmLabel"
id="scmSelect"
label="scmLabel"
value={value}
onChange={onChange}
onBlur={onBlur}
>
<MenuItem value="AUTO">Auto-detect</MenuItem>
<MenuItem value="gitlab">GitLab</MenuItem>
<MenuItem value="bitbucket/api">Bitbucket</MenuItem>
<MenuItem value="azure/api">Azure</MenuItem>
</Select>
)}
/>
</FormControl>
<Button
id="registerComponentFormSubmit"
data-testid="registerComponentFormSubmit"
variant="contained"
color="primary"
type="submit"
@@ -82,7 +82,7 @@ export const RegisterComponentPage = ({
const handleSubmit = async (formData: Record<string, string>) => {
setFormState(FormStates.Submitting);
const { componentLocation: target } = formData;
const { scmType, componentLocation: target } = formData;
try {
const typeMapping = [
{ url: /https:\/\/gitlab\.com\/.*/, type: 'gitlab' },
@@ -91,8 +91,10 @@ export const RegisterComponentPage = ({
{ url: /.*/, type: 'github' },
];
const type = typeMapping.filter(item => item.url.test(target))[0].type;
const type =
scmType === 'AUTO'
? typeMapping.filter(item => item.url.test(target))[0].type
: scmType;
const data = await catalogApi.addLocation(type, target);
if (!isMounted()) return;
+5 -1
View File
@@ -17,7 +17,7 @@
import os from 'os';
import path from 'path';
import parseGitUrl from 'git-url-parse';
import { Clone, Repository } from 'nodegit';
import NodeGit, { Clone, Repository } from 'nodegit';
import fs from 'fs-extra';
// @ts-ignore
import defaultBranch from 'default-branch';
@@ -26,6 +26,10 @@ import { InputError } from '@backstage/backend-common';
import { RemoteProtocol } from './techdocs/stages/prepare/types';
import { Logger } from 'winston';
// Enables core.longpaths on windows to prevent crashing when checking out repos with long foldernames and/or deep nesting
// @ts-ignore
NodeGit.Libgit2.opts(28, 1);
export type ParsedLocationAnnotation = {
type: RemoteProtocol;
target: string;