Merge branch 'master' into patch/sidebar-submenu-fix

Signed-off-by: hiba-aldalaty <hibaaldalaty@gmail.com>
This commit is contained in:
hiba-aldalaty
2021-12-08 12:43:14 +00:00
176 changed files with 1646 additions and 1228 deletions
+4 -2
View File
@@ -35,9 +35,11 @@
"@backstage/theme": "^0.2.14",
"@material-ui/core": "^4.12.2",
"@material-ui/icons": "^4.9.1",
"react": "^16.12.0",
"react-router-dom": "6.0.0-beta.0"
},
"peerDependencies": {
"react": "^16.13.1 || ^17.0.0"
},
"devDependencies": {
"@backstage/cli": "^0.10.0",
"@backstage/test-utils": "^0.1.22",
@@ -45,7 +47,7 @@
"@testing-library/react": "^11.2.5",
"@types/jest": "^26.0.7",
"@types/node": "^14.14.32",
"@types/react": "*"
"@types/react": "^16.13.1 || ^17.0.0"
},
"files": [
"dist"
+2 -2
View File
@@ -56,8 +56,8 @@
"@roadiehq/backstage-plugin-travis-ci": "^1.0.11",
"history": "^5.0.0",
"prop-types": "^15.7.2",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-hot-loader": "^4.12.21",
"react-router": "6.0.0-beta.0",
"react-router-dom": "6.0.0-beta.0",
+35 -71
View File
@@ -175,23 +175,22 @@ export function createStatusCheckRouter(options: {
// @public (undocumented)
export class DatabaseManager {
forPlugin(pluginId: string): PluginDatabaseManager;
static fromConfig(config: Config): DatabaseManager;
static fromConfig(
config: Config,
options?: DatabaseManagerOptions,
): DatabaseManager;
}
// @public
export type DatabaseManagerOptions = {
migrations?: PluginDatabaseManager['migrations'];
};
// @public (undocumented)
export class DockerContainerRunner implements ContainerRunner {
constructor({ dockerClient }: { dockerClient: Docker });
constructor(options: { dockerClient: Docker });
// (undocumented)
runContainer({
imageName,
command,
args,
logStream,
mountDirs,
workingDir,
envVars,
pullImage,
}: RunContainerOptions): Promise<void>;
runContainer(options: RunContainerOptions): Promise<void>;
}
// @public
@@ -227,34 +226,17 @@ export function getVoidLogger(): winston.Logger;
// @public (undocumented)
export class Git {
// (undocumented)
add({ dir, filepath }: { dir: string; filepath: string }): Promise<void>;
add(options: { dir: string; filepath: string }): Promise<void>;
// (undocumented)
addRemote({
dir,
url,
remote,
}: {
addRemote(options: {
dir: string;
remote: string;
url: string;
}): Promise<void>;
// (undocumented)
clone({
url,
dir,
ref,
}: {
url: string;
dir: string;
ref?: string;
}): Promise<void>;
clone(options: { url: string; dir: string; ref?: string }): Promise<void>;
// (undocumented)
commit({
dir,
message,
author,
committer,
}: {
commit(options: {
dir: string;
message: string;
author: {
@@ -267,41 +249,22 @@ export class Git {
};
}): Promise<string>;
// (undocumented)
currentBranch({
dir,
fullName,
}: {
currentBranch(options: {
dir: string;
fullName?: boolean;
}): Promise<string | undefined>;
// (undocumented)
fetch({ dir, remote }: { dir: string; remote?: string }): Promise<void>;
fetch(options: { dir: string; remote?: string }): Promise<void>;
// (undocumented)
static fromAuth: ({
username,
password,
logger,
}: {
username?: string | undefined;
password?: string | undefined;
logger?: Logger_2 | undefined;
static fromAuth: (options: {
username?: string;
password?: string;
logger?: Logger_2;
}) => Git;
// (undocumented)
init({
dir,
defaultBranch,
}: {
dir: string;
defaultBranch?: string;
}): Promise<void>;
init(options: { dir: string; defaultBranch?: string }): Promise<void>;
// (undocumented)
merge({
dir,
theirs,
ours,
author,
committer,
}: {
merge(options: {
dir: string;
theirs: string;
ours?: string;
@@ -315,17 +278,11 @@ export class Git {
};
}): Promise<MergeResult>;
// (undocumented)
push({ dir, remote }: { dir: string; remote: string }): Promise<PushResult>;
push(options: { dir: string; remote: string }): Promise<PushResult>;
// (undocumented)
readCommit({
dir,
sha,
}: {
dir: string;
sha: string;
}): Promise<ReadCommitResult>;
readCommit(options: { dir: string; sha: string }): Promise<ReadCommitResult>;
// (undocumented)
resolveRef({ dir, ref }: { dir: string; ref: string }): Promise<string>;
resolveRef(options: { dir: string; ref: string }): Promise<string>;
}
// @public
@@ -395,6 +352,9 @@ export type PluginCacheManager = {
// @public
export interface PluginDatabaseManager {
getClient(): Promise<Knex>;
migrations?: {
skip?: boolean;
};
}
// @public
@@ -623,8 +583,8 @@ export type UrlReaderPredicateTuple = {
// @public
export class UrlReaders {
static create({ logger, config, factories }: UrlReadersOptions): UrlReader;
static default({ logger, config, factories }: UrlReadersOptions): UrlReader;
static create(options: UrlReadersOptions): UrlReader;
static default(options: UrlReadersOptions): UrlReader;
}
// @public (undocumented)
@@ -642,4 +602,8 @@ export function useHotCleanup(
// @public
export function useHotMemoize<T>(_module: NodeModule, valueFactory: () => T): T;
// Warnings were encountered during analysis:
//
// src/database/types.d.ts:23:12 - (tsdoc-undefined-tag) The TSDoc tag "@default" is not defined in this configuration
```
@@ -36,25 +36,45 @@ describe('DatabaseManager', () => {
afterEach(() => jest.resetAllMocks());
describe('DatabaseManager.fromConfig', () => {
it('accesses the backend.database key', () => {
const config = new ConfigReader({
backend: {
database: {
client: 'pg',
connection: {
host: 'localhost',
user: 'foo',
password: 'bar',
database: 'foodb',
},
const backendConfig = {
backend: {
database: {
client: 'pg',
connection: {
host: 'localhost',
user: 'foo',
password: 'bar',
database: 'foodb',
},
},
});
},
};
it('accesses the backend.database key', () => {
const config = new ConfigReader(backendConfig);
const getConfigSpy = jest.spyOn(config, 'getConfig');
DatabaseManager.fromConfig(config);
expect(getConfigSpy).toHaveBeenCalledWith('backend.database');
});
it('handles default options', () => {
const config = new ConfigReader(backendConfig);
const database = DatabaseManager.fromConfig(config);
const client = database.forPlugin('test');
expect(client.migrations?.skip).toBe(false);
});
it('handles migrations options', () => {
const config = new ConfigReader(backendConfig);
const database = DatabaseManager.fromConfig(config, {
migrations: { skip: true },
});
const client = database.forPlugin('test');
expect(client.migrations?.skip).toBe(true);
});
});
describe('DatabaseManager.forPlugin', () => {
@@ -36,6 +36,15 @@ function pluginPath(pluginId: string): string {
return `plugin.${pluginId}`;
}
/**
* Configuration options object.
*
* @public
*/
export type DatabaseManagerOptions = {
migrations?: PluginDatabaseManager['migrations'];
};
/** @public */
export class DatabaseManager {
/**
@@ -47,19 +56,25 @@ export class DatabaseManager {
* names if config is not provided.
*
* @param config - The loaded application configuration.
* @param options - An optional configuration object.
*/
static fromConfig(config: Config): DatabaseManager {
static fromConfig(
config: Config,
options?: DatabaseManagerOptions,
): DatabaseManager {
const databaseConfig = config.getConfig('backend.database');
return new DatabaseManager(
databaseConfig,
databaseConfig.getOptionalString('prefix'),
options,
);
}
private constructor(
private readonly config: Config,
private readonly prefix: string = 'backstage_plugin_',
private readonly options?: DatabaseManagerOptions,
) {}
/**
@@ -76,6 +91,10 @@ export class DatabaseManager {
getClient(): Promise<Knex> {
return _this.getDatabase(pluginId);
},
migrations: {
skip: false,
..._this.options?.migrations,
},
};
}
@@ -30,6 +30,18 @@ export interface PluginDatabaseManager {
* stores so that plugins are discouraged from database integration.
*/
getClient(): Promise<Knex>;
/**
* This property is used to control the behavior of database migrations.
*/
migrations?: {
/**
* skip database migrations. Useful if connecting to a read-only database.
*
* @default false
*/
skip?: boolean;
};
}
/**
@@ -46,7 +46,8 @@ export class UrlReaders {
/**
* Creates a UrlReader without any known types.
*/
static create({ logger, config, factories }: UrlReadersOptions): UrlReader {
static create(options: UrlReadersOptions): UrlReader {
const { logger, config, factories } = options;
const mux = new UrlReaderPredicateMux(logger);
const treeResponseFactory = DefaultReadTreeResponseFactory.create({
config,
@@ -68,7 +69,8 @@ export class UrlReaders {
*
* Any additional factories passed will be loaded before the default ones.
*/
static default({ logger, config, factories = [] }: UrlReadersOptions) {
static default(options: UrlReadersOptions) {
const { logger, config, factories = [] } = options;
return UrlReaders.create({
logger,
config,
+32 -74
View File
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import git, {
ProgressCallback,
MergeResult,
@@ -42,44 +43,32 @@ export class Git {
},
) {}
async add({
dir,
filepath,
}: {
dir: string;
filepath: string;
}): Promise<void> {
async add(options: { dir: string; filepath: string }): Promise<void> {
const { dir, filepath } = options;
this.config.logger?.info(`Adding file {dir=${dir},filepath=${filepath}}`);
return git.add({ fs, dir, filepath });
}
async addRemote({
dir,
url,
remote,
}: {
async addRemote(options: {
dir: string;
remote: string;
url: string;
}): Promise<void> {
const { dir, url, remote } = options;
this.config.logger?.info(
`Creating new remote {dir=${dir},remote=${remote},url=${url}}`,
);
return git.addRemote({ fs, dir, remote, url });
}
async commit({
dir,
message,
author,
committer,
}: {
async commit(options: {
dir: string;
message: string;
author: { name: string; email: string };
committer: { name: string; email: string };
}): Promise<string> {
const { dir, message, author, committer } = options;
this.config.logger?.info(
`Committing file to repo {dir=${dir},message=${message}}`,
);
@@ -87,15 +76,12 @@ export class Git {
return git.commit({ fs, dir, message, author, committer });
}
async clone({
url,
dir,
ref,
}: {
async clone(options: {
url: string;
dir: string;
ref?: string;
}): Promise<void> {
const { url, dir, ref } = options;
this.config.logger?.info(`Cloning repo {dir=${dir},url=${url}}`);
return git.clone({
fs,
@@ -114,51 +100,35 @@ export class Git {
}
// https://isomorphic-git.org/docs/en/currentBranch
async currentBranch({
dir,
fullName,
}: {
async currentBranch(options: {
dir: string;
fullName?: boolean;
}): Promise<string | undefined> {
const fullname = fullName ?? false;
return git.currentBranch({ fs, dir, fullname }) as Promise<
const { dir, fullName = false } = options;
return git.currentBranch({ fs, dir, fullname: fullName }) as Promise<
string | undefined
>;
}
// https://isomorphic-git.org/docs/en/fetch
async fetch({
dir,
remote,
}: {
dir: string;
remote?: string;
}): Promise<void> {
const remoteValue = remote ?? 'origin';
async fetch(options: { dir: string; remote?: string }): Promise<void> {
const { dir, remote = 'origin' } = options;
this.config.logger?.info(
`Fetching remote=${remoteValue} for repository {dir=${dir}}`,
`Fetching remote=${remote} for repository {dir=${dir}}`,
);
await git.fetch({
fs,
http,
dir,
remote: remoteValue,
remote,
onProgress: this.onProgressHandler(),
headers: {
'user-agent': 'git/@isomorphic-git',
},
headers: { 'user-agent': 'git/@isomorphic-git' },
onAuth: this.onAuth,
});
}
async init({
dir,
defaultBranch = 'master',
}: {
dir: string;
defaultBranch?: string;
}): Promise<void> {
async init(options: { dir: string; defaultBranch?: string }): Promise<void> {
const { dir, defaultBranch = 'master' } = options;
this.config.logger?.info(`Init git repository {dir=${dir}}`);
return git.init({
@@ -169,19 +139,14 @@ export class Git {
}
// https://isomorphic-git.org/docs/en/merge
async merge({
dir,
theirs,
ours,
author,
committer,
}: {
async merge(options: {
dir: string;
theirs: string;
ours?: string;
author: { name: string; email: string };
committer: { name: string; email: string };
}): Promise<MergeResult> {
const { dir, theirs, ours, author, committer } = options;
this.config.logger?.info(
`Merging branch '${theirs}' into '${ours}' for repository {dir=${dir}}`,
);
@@ -197,7 +162,8 @@ export class Git {
});
}
async push({ dir, remote }: { dir: string; remote: string }) {
async push(options: { dir: string; remote: string }) {
const { dir, remote } = options;
this.config.logger?.info(
`Pushing directory to remote {dir=${dir},remote=${remote}}`,
);
@@ -215,24 +181,17 @@ export class Git {
}
// https://isomorphic-git.org/docs/en/readCommit
async readCommit({
dir,
sha,
}: {
async readCommit(options: {
dir: string;
sha: string;
}): Promise<ReadCommitResult> {
const { dir, sha } = options;
return git.readCommit({ fs, dir, oid: sha });
}
// https://isomorphic-git.org/docs/en/resolveRef
async resolveRef({
dir,
ref,
}: {
dir: string;
ref: string;
}): Promise<string> {
async resolveRef(options: { dir: string; ref: string }): Promise<string> {
const { dir, ref } = options;
return git.resolveRef({ fs, dir, ref });
}
@@ -256,13 +215,12 @@ export class Git {
};
};
static fromAuth = ({
username,
password,
logger,
}: {
static fromAuth = (options: {
username?: string;
password?: string;
logger?: Logger;
}) => new Git({ username, password, logger });
}) => {
const { username, password, logger } = options;
return new Git({ username, password, logger });
};
}
@@ -28,20 +28,22 @@ export type UserOptions = {
export class DockerContainerRunner implements ContainerRunner {
private readonly dockerClient: Docker;
constructor({ dockerClient }: { dockerClient: Docker }) {
this.dockerClient = dockerClient;
constructor(options: { dockerClient: Docker }) {
this.dockerClient = options.dockerClient;
}
async runContainer({
imageName,
command,
args,
logStream = new PassThrough(),
mountDirs = {},
workingDir,
envVars = {},
pullImage = true,
}: RunContainerOptions) {
async runContainer(options: RunContainerOptions) {
const {
imageName,
command,
args,
logStream = new PassThrough(),
mountDirs = {},
workingDir,
envVars = {},
pullImage = true,
} = options;
// Show a better error message when Docker is unavailable.
try {
await this.dockerClient.ping();
-1
View File
@@ -89,7 +89,6 @@
"ora": "^5.3.0",
"postcss": "^8.1.0",
"process": "^0.11.10",
"react": "^16.0.0",
"react-dev-utils": "^12.0.0-next.47",
"react-hot-loader": "^4.12.21",
"recursive-readdir": "^2.2.2",
+21 -3
View File
@@ -75,7 +75,9 @@ class PackageJsonHandler {
await this.syncScripts();
await this.syncPublishConfig();
await this.syncDependencies('dependencies');
await this.syncDependencies('peerDependencies', true);
await this.syncDependencies('devDependencies');
await this.syncReactDeps();
}
// Make sure a field inside package.json is in sync. This mutates the targetObj and writes package.json on change.
@@ -207,12 +209,12 @@ class PackageJsonHandler {
}
}
private async syncDependencies(fieldName: string) {
private async syncDependencies(fieldName: string, required: boolean = false) {
const pkgDeps = this.pkg[fieldName];
const targetDeps = (this.targetPkg[fieldName] =
this.targetPkg[fieldName] || {});
if (!pkgDeps) {
if (!pkgDeps && !required) {
return;
}
@@ -231,10 +233,26 @@ class PackageJsonHandler {
continue;
}
await this.syncField(key, pkgDeps, targetDeps, fieldName, true, true);
await this.syncField(
key,
pkgDeps,
targetDeps,
fieldName,
true,
!required,
);
}
}
private async syncReactDeps() {
const targetDeps = (this.targetPkg.dependencies =
this.targetPkg.dependencies || {});
// Remove these from from deps since they're now in peerDeps
await this.syncField('react', {}, targetDeps, 'dependencies');
await this.syncField('react-dom', {}, targetDeps, 'dependencies');
}
private async write() {
await this.writeFunc(`${JSON.stringify(this.targetPkg, null, 2)}\n`);
}
+2 -2
View File
@@ -66,7 +66,7 @@ export const version = findVersion();
export const isDev = fs.pathExistsSync(paths.resolveOwn('src'));
export function createPackageVersionProvider(lockfile?: Lockfile) {
return (name: string, versionHint?: string) => {
return (name: string, versionHint?: string): string => {
const packageVersion = packageVersions[name];
const targetVersion = versionHint || packageVersion;
if (!targetVersion) {
@@ -94,6 +94,6 @@ export function createPackageVersionProvider(lockfile?: Lockfile) {
if (semver.parse(versionHint)?.prerelease.length) {
return versionHint!;
}
return `^${versionHint}`;
return versionHint?.match(/^[\d\.]+$/) ? `^${versionHint}` : versionHint!;
};
}
@@ -32,10 +32,11 @@
"@material-ui/core": "{{versionQuery '@material-ui/core' '4.12.2'}}",
"@material-ui/icons": "{{versionQuery '@material-ui/icons' '4.9.1'}}",
"@material-ui/lab": "{{versionQuery '@material-ui/lab' '4.0.0-alpha.57'}}",
"react": "{{versionQuery 'react' '16.13.1'}}",
"react-dom": "{{versionQuery 'react-dom' '16.13.1'}}",
"react-use": "{{versionQuery 'react-use' '17.2.4'}}"
},
"peerDependencies": {
"react": "{{versionQuery 'react' '^16.13.1 || ^17.0.0'}}"
},
"devDependencies": {
"@backstage/cli": "{{versionQuery '@backstage/cli'}}",
"@backstage/core-app-api": "{{versionQuery '@backstage/core-app-api'}}",
+13 -74
View File
@@ -250,24 +250,13 @@ export class AppThemeSelector implements AppThemeApi {
// @public
export class AtlassianAuth {
// (undocumented)
static create({
discoveryApi,
environment,
provider,
oauthRequestApi,
}: OAuthApiCreateOptions): typeof atlassianAuthApiRef.T;
static create(options: OAuthApiCreateOptions): typeof atlassianAuthApiRef.T;
}
// @public
export class Auth0Auth {
// (undocumented)
static create({
discoveryApi,
environment,
provider,
oauthRequestApi,
defaultScopes,
}: OAuthApiCreateOptions): typeof auth0AuthApiRef.T;
static create(options: OAuthApiCreateOptions): typeof auth0AuthApiRef.T;
}
// @public
@@ -303,13 +292,7 @@ export type BackstagePluginWithAnyOutput = Omit<
// @public
export class BitbucketAuth {
// (undocumented)
static create({
discoveryApi,
environment,
provider,
oauthRequestApi,
defaultScopes,
}: OAuthApiCreateOptions): typeof bitbucketAuthApiRef.T;
static create(options: OAuthApiCreateOptions): typeof bitbucketAuthApiRef.T;
}
// @public
@@ -402,13 +385,7 @@ export class GithubAuth implements OAuthApi, SessionApi {
// @deprecated
constructor(sessionManager: SessionManager<GithubSession>);
// (undocumented)
static create({
discoveryApi,
environment,
provider,
oauthRequestApi,
defaultScopes,
}: OAuthApiCreateOptions): GithubAuth;
static create(options: OAuthApiCreateOptions): GithubAuth;
// (undocumented)
getAccessToken(scope?: string, options?: AuthRequestOptions): Promise<string>;
// (undocumented)
@@ -441,25 +418,13 @@ export type GithubSession = {
// @public
export class GitlabAuth {
// (undocumented)
static create({
discoveryApi,
environment,
provider,
oauthRequestApi,
defaultScopes,
}: OAuthApiCreateOptions): typeof gitlabAuthApiRef.T;
static create(options: OAuthApiCreateOptions): typeof gitlabAuthApiRef.T;
}
// @public
export class GoogleAuth {
// (undocumented)
static create({
discoveryApi,
oauthRequestApi,
environment,
provider,
defaultScopes,
}: OAuthApiCreateOptions): typeof googleAuthApiRef.T;
static create(options: OAuthApiCreateOptions): typeof googleAuthApiRef.T;
}
// @public
@@ -477,13 +442,7 @@ export class LocalStorageFeatureFlags implements FeatureFlagsApi {
// @public
export class MicrosoftAuth {
// (undocumented)
static create({
environment,
provider,
oauthRequestApi,
discoveryApi,
defaultScopes,
}: OAuthApiCreateOptions): typeof microsoftAuthApiRef.T;
static create(options: OAuthApiCreateOptions): typeof microsoftAuthApiRef.T;
}
// @public
@@ -507,14 +466,7 @@ export class OAuth2
scopeTransform: (scopes: string[]) => string[];
});
// (undocumented)
static create({
discoveryApi,
environment,
provider,
oauthRequestApi,
defaultScopes,
scopeTransform,
}: OAuth2CreateOptions): OAuth2;
static create(options: OAuth2CreateOptions): OAuth2;
// (undocumented)
getAccessToken(
scope?: string | string[],
@@ -570,24 +522,15 @@ export class OAuthRequestManager implements OAuthRequestApi {
// @public
export class OktaAuth {
// (undocumented)
static create({
discoveryApi,
environment,
provider,
oauthRequestApi,
defaultScopes,
}: OAuthApiCreateOptions): typeof oktaAuthApiRef.T;
static create(options: OAuthApiCreateOptions): typeof oktaAuthApiRef.T;
}
// @public
export class OneLoginAuth {
// (undocumented)
static create({
discoveryApi,
environment,
provider,
oauthRequestApi,
}: OneLoginAuthCreateOptions): typeof oneloginAuthApiRef.T;
static create(
options: OneLoginAuthCreateOptions,
): typeof oneloginAuthApiRef.T;
}
// @public
@@ -607,11 +550,7 @@ export class SamlAuth
// @deprecated
constructor(sessionManager: SessionManager<SamlSession>);
// (undocumented)
static create({
discoveryApi,
environment,
provider,
}: AuthApiCreateOptions): SamlAuth;
static create(options: AuthApiCreateOptions): SamlAuth;
// (undocumented)
getBackstageIdentity(
options?: AuthRequestOptions,
+4 -2
View File
@@ -38,14 +38,16 @@
"@backstage/version-bridge": "^0.1.0",
"@material-ui/core": "^4.12.2",
"@material-ui/icons": "^4.9.1",
"@types/react": "*",
"@types/prop-types": "^15.7.3",
"prop-types": "^15.7.2",
"react": "^16.12.0",
"react-router-dom": "6.0.0-beta.0",
"react-use": "^17.2.4",
"zen-observable": "^0.8.15"
},
"peerDependencies": {
"@types/react": "^16.13.1 || ^17.0.0",
"react": "^16.13.1 || ^17.0.0"
},
"devDependencies": {
"@backstage/cli": "^0.10.0",
"@backstage/test-utils": "^0.1.23",
@@ -30,12 +30,14 @@ const DEFAULT_PROVIDER = {
* @public
*/
export default class AtlassianAuth {
static create({
discoveryApi,
environment = 'development',
provider = DEFAULT_PROVIDER,
oauthRequestApi,
}: OAuthApiCreateOptions): typeof atlassianAuthApiRef.T {
static create(options: OAuthApiCreateOptions): typeof atlassianAuthApiRef.T {
const {
discoveryApi,
environment = 'development',
provider = DEFAULT_PROVIDER,
oauthRequestApi,
} = options;
return OAuth2.create({
discoveryApi,
oauthRequestApi,
@@ -30,13 +30,15 @@ const DEFAULT_PROVIDER = {
* @public
*/
export default class Auth0Auth {
static create({
discoveryApi,
environment = 'development',
provider = DEFAULT_PROVIDER,
oauthRequestApi,
defaultScopes = ['openid', `email`, `profile`],
}: OAuthApiCreateOptions): typeof auth0AuthApiRef.T {
static create(options: OAuthApiCreateOptions): typeof auth0AuthApiRef.T {
const {
discoveryApi,
environment = 'development',
provider = DEFAULT_PROVIDER,
oauthRequestApi,
defaultScopes = ['openid', `email`, `profile`],
} = options;
return OAuth2.create({
discoveryApi,
oauthRequestApi,
@@ -45,13 +45,15 @@ const DEFAULT_PROVIDER = {
* @public
*/
export default class BitbucketAuth {
static create({
discoveryApi,
environment = 'development',
provider = DEFAULT_PROVIDER,
oauthRequestApi,
defaultScopes = ['team'],
}: OAuthApiCreateOptions): typeof bitbucketAuthApiRef.T {
static create(options: OAuthApiCreateOptions): typeof bitbucketAuthApiRef.T {
const {
discoveryApi,
environment = 'development',
provider = DEFAULT_PROVIDER,
oauthRequestApi,
defaultScopes = ['team'],
} = options;
return OAuth2.create({
discoveryApi,
oauthRequestApi,
@@ -56,13 +56,15 @@ const DEFAULT_PROVIDER = {
* @public
*/
export default class GithubAuth implements OAuthApi, SessionApi {
static create({
discoveryApi,
environment = 'development',
provider = DEFAULT_PROVIDER,
oauthRequestApi,
defaultScopes = ['read:user'],
}: OAuthApiCreateOptions) {
static create(options: OAuthApiCreateOptions) {
const {
discoveryApi,
environment = 'development',
provider = DEFAULT_PROVIDER,
oauthRequestApi,
defaultScopes = ['read:user'],
} = options;
const connector = new DefaultAuthConnector({
discoveryApi,
environment,
@@ -30,13 +30,15 @@ const DEFAULT_PROVIDER = {
* @public
*/
export default class GitlabAuth {
static create({
discoveryApi,
environment = 'development',
provider = DEFAULT_PROVIDER,
oauthRequestApi,
defaultScopes = ['read_user'],
}: OAuthApiCreateOptions): typeof gitlabAuthApiRef.T {
static create(options: OAuthApiCreateOptions): typeof gitlabAuthApiRef.T {
const {
discoveryApi,
environment = 'development',
provider = DEFAULT_PROVIDER,
oauthRequestApi,
defaultScopes = ['read_user'],
} = options;
return OAuth2.create({
discoveryApi,
oauthRequestApi,
@@ -32,17 +32,19 @@ const SCOPE_PREFIX = 'https://www.googleapis.com/auth/';
* @public
*/
export default class GoogleAuth {
static create({
discoveryApi,
oauthRequestApi,
environment = 'development',
provider = DEFAULT_PROVIDER,
defaultScopes = [
'openid',
`${SCOPE_PREFIX}userinfo.email`,
`${SCOPE_PREFIX}userinfo.profile`,
],
}: OAuthApiCreateOptions): typeof googleAuthApiRef.T {
static create(options: OAuthApiCreateOptions): typeof googleAuthApiRef.T {
const {
discoveryApi,
oauthRequestApi,
environment = 'development',
provider = DEFAULT_PROVIDER,
defaultScopes = [
'openid',
`${SCOPE_PREFIX}userinfo.email`,
`${SCOPE_PREFIX}userinfo.profile`,
],
} = options;
return OAuth2.create({
discoveryApi,
oauthRequestApi,
@@ -30,19 +30,21 @@ const DEFAULT_PROVIDER = {
* @public
*/
export default class MicrosoftAuth {
static create({
environment = 'development',
provider = DEFAULT_PROVIDER,
oauthRequestApi,
discoveryApi,
defaultScopes = [
'openid',
'offline_access',
'profile',
'email',
'User.Read',
],
}: OAuthApiCreateOptions): typeof microsoftAuthApiRef.T {
static create(options: OAuthApiCreateOptions): typeof microsoftAuthApiRef.T {
const {
environment = 'development',
provider = DEFAULT_PROVIDER,
oauthRequestApi,
discoveryApi,
defaultScopes = [
'openid',
'offline_access',
'profile',
'email',
'User.Read',
],
} = options;
return OAuth2.create({
discoveryApi,
oauthRequestApi,
@@ -70,14 +70,16 @@ export default class OAuth2
BackstageIdentityApi,
SessionApi
{
static create({
discoveryApi,
environment = 'development',
provider = DEFAULT_PROVIDER,
oauthRequestApi,
defaultScopes = [],
scopeTransform = x => x,
}: OAuth2CreateOptions) {
static create(options: OAuth2CreateOptions) {
const {
discoveryApi,
environment = 'development',
provider = DEFAULT_PROVIDER,
oauthRequestApi,
defaultScopes = [],
scopeTransform = x => x,
} = options;
const connector = new DefaultAuthConnector({
discoveryApi,
environment,
@@ -42,13 +42,15 @@ const OKTA_SCOPE_PREFIX: string = 'okta.';
* @public
*/
export default class OktaAuth {
static create({
discoveryApi,
environment = 'development',
provider = DEFAULT_PROVIDER,
oauthRequestApi,
defaultScopes = ['openid', 'email', 'profile', 'offline_access'],
}: OAuthApiCreateOptions): typeof oktaAuthApiRef.T {
static create(options: OAuthApiCreateOptions): typeof oktaAuthApiRef.T {
const {
discoveryApi,
environment = 'development',
provider = DEFAULT_PROVIDER,
oauthRequestApi,
defaultScopes = ['openid', 'email', 'profile', 'offline_access'],
} = options;
return OAuth2.create({
discoveryApi,
oauthRequestApi,
@@ -57,12 +57,16 @@ const SCOPE_PREFIX: string = 'onelogin.';
* @public
*/
export default class OneLoginAuth {
static create({
discoveryApi,
environment = 'development',
provider = DEFAULT_PROVIDER,
oauthRequestApi,
}: OneLoginAuthCreateOptions): typeof oneloginAuthApiRef.T {
static create(
options: OneLoginAuthCreateOptions,
): typeof oneloginAuthApiRef.T {
const {
discoveryApi,
environment = 'development',
provider = DEFAULT_PROVIDER,
oauthRequestApi,
} = options;
return OAuth2.create({
discoveryApi,
oauthRequestApi,
@@ -52,11 +52,13 @@ const DEFAULT_PROVIDER = {
export default class SamlAuth
implements ProfileInfoApi, BackstageIdentityApi, SessionApi
{
static create({
discoveryApi,
environment = 'development',
provider = DEFAULT_PROVIDER,
}: AuthApiCreateOptions) {
static create(options: AuthApiCreateOptions) {
const {
discoveryApi,
environment = 'development',
provider = DEFAULT_PROVIDER,
} = options;
const connector = new DirectAuthConnector<SamlSession>({
discoveryApi,
environment,
+1 -4
View File
@@ -1982,10 +1982,7 @@ export const SidebarSpacer: React_2.ComponentType<
>;
// @public
export const SidebarSubmenu: ({
title,
children,
}: PropsWithChildren<SidebarSubmenuProps>) => JSX.Element;
export const SidebarSubmenu: (props: SidebarSubmenuProps) => JSX.Element;
// @public
export const SidebarSubmenuItem: (
+5 -3
View File
@@ -37,7 +37,6 @@
"@material-ui/core": "^4.12.2",
"@material-ui/icons": "^4.9.1",
"@material-ui/lab": "4.0.0-alpha.57",
"@types/react": "*",
"@types/react-sparklines": "^1.7.0",
"@types/react-text-truncate": "^0.14.0",
"classnames": "^2.2.6",
@@ -53,8 +52,6 @@
"prop-types": "^15.7.2",
"qs": "^6.9.4",
"rc-progress": "^3.0.0",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react-helmet": "6.1.0",
"react-hook-form": "^7.12.2",
"react-markdown": "^7.0.1",
@@ -67,6 +64,11 @@
"remark-gfm": "^2.0.0",
"zen-observable": "^0.8.15"
},
"peerDependencies": {
"@types/react": "^16.13.1 || ^17.0.0",
"react": "^16.13.1 || ^17.0.0",
"react-dom": "^16.13.1 || ^17.0.0"
},
"devDependencies": {
"@backstage/core-app-api": "^0.1.24",
"@backstage/cli": "^0.10.0",
@@ -15,8 +15,7 @@
*/
import React from 'react';
import { fireEvent } from '@testing-library/react';
import { act } from 'react-dom/test-utils';
import { act, fireEvent } from '@testing-library/react';
import { renderInTestApp, TestApiProvider } from '@backstage/test-utils';
import { CopyTextButton } from './CopyTextButton';
import { errorApiRef } from '@backstage/core-plugin-api';
@@ -16,7 +16,7 @@
import React from 'react';
import { renderInTestApp } from '@backstage/test-utils';
import { act } from 'react-dom/test-utils';
import { act } from '@testing-library/react';
import { Progress } from './Progress';
@@ -14,9 +14,8 @@
* limitations under the License.
*/
import { renderInTestApp } from '@backstage/test-utils';
import { fireEvent } from '@testing-library/react';
import { act, fireEvent } from '@testing-library/react';
import React from 'react';
import { act } from 'react-dom/test-utils';
import { Route, Routes } from 'react-router';
import { RoutedTabs } from './RoutedTabs';
@@ -14,9 +14,8 @@
* limitations under the License.
*/
import { renderInTestApp, withLogCollector } from '@backstage/test-utils';
import { fireEvent } from '@testing-library/react';
import { act, fireEvent } from '@testing-library/react';
import React from 'react';
import { act } from 'react-dom/test-utils';
import { Route, Routes } from 'react-router';
import { TabbedLayout } from './TabbedLayout';
@@ -236,7 +236,7 @@ const SidebarItemWithSubmenu = ({
{itemIcon}
</div>
{text && (
<Typography variant="subtitle2" className={classes.text}>
<Typography variant="subtitle2" className={classes.label}>
{text}
</Typography>
)}
@@ -403,7 +403,7 @@ export const SidebarItem = forwardRef<any, SidebarItemProps>((props, ref) => {
{itemIcon}
</div>
{text && (
<Typography variant="subtitle2" className={classes.text}>
<Typography variant="subtitle2" className={classes.label}>
{text}
</Typography>
)}
@@ -16,7 +16,7 @@
import { makeStyles } from '@material-ui/core/styles';
import Typography from '@material-ui/core/Typography';
import clsx from 'clsx';
import React, { PropsWithChildren, ReactNode, useContext } from 'react';
import React, { ReactNode, useContext } from 'react';
import {
SidebarItemWithSubmenuContext,
sidebarConfig,
@@ -83,16 +83,12 @@ export type SidebarSubmenuProps = {
*
* @public
*/
export const SidebarSubmenu = ({
title,
children,
}: PropsWithChildren<SidebarSubmenuProps>) => {
export const SidebarSubmenu = (props: SidebarSubmenuProps) => {
const { isOpen } = useContext(SidebarContext);
const left = isOpen
? sidebarConfig.drawerWidthOpen
: sidebarConfig.drawerWidthClosed;
const props = { left: left };
const classes = useStyles(props)();
const classes = useStyles({ left: left })();
const { isHoveredOn } = useContext(SidebarItemWithSubmenuContext);
return (
@@ -102,9 +98,9 @@ export const SidebarSubmenu = ({
})}
>
<Typography variant="h5" className={classes.title}>
{title}
{props.title}
</Typography>
{children}
{props.children}
</div>
);
};
+1 -4
View File
@@ -43,10 +43,7 @@ export type AnalyticsApi = {
export const analyticsApiRef: ApiRef<AnalyticsApi>;
// @public
export const AnalyticsContext: ({
attributes,
children,
}: {
export const AnalyticsContext: (options: {
attributes: Partial<AnalyticsContextValue>;
children: ReactNode;
}) => JSX.Element;
+4 -2
View File
@@ -34,14 +34,16 @@
"@backstage/types": "^0.1.1",
"@backstage/version-bridge": "^0.1.0",
"@material-ui/core": "^4.12.2",
"@types/react": "*",
"history": "^5.0.0",
"prop-types": "^15.7.2",
"react": "^16.12.0",
"react-router-dom": "6.0.0-beta.0",
"react-use": "^17.2.4",
"zen-observable": "^0.8.15"
},
"peerDependencies": {
"@types/react": "^16.13.1 || ^17.0.0",
"react": "^16.13.1 || ^17.0.0"
},
"devDependencies": {
"@backstage/cli": "^0.10.0",
"@backstage/core-app-api": "^0.1.24",
@@ -62,13 +62,12 @@ export const useAnalyticsContext = (): AnalyticsContextValue => {
*
* @public
*/
export const AnalyticsContext = ({
attributes,
children,
}: {
export const AnalyticsContext = (options: {
attributes: Partial<AnalyticsContextValue>;
children: ReactNode;
}) => {
const { attributes, children } = options;
const parentValues = useAnalyticsContext();
const combinedValue = {
...parentValues,
+1 -1
View File
@@ -22,4 +22,4 @@ yarn backstage-create-app
## Documentation
- [Backstage Readme](https://github.com/backstage/backstage/blob/master/README.md)
- [Backstage Documentation](https://github.com/backstage/backstage/blob/master/docs/README.md)
- [Backstage Documentation](https://backstage.io/docs/)
+1 -1
View File
@@ -65,7 +65,7 @@ export default async (cmd: Command, version: string): Promise<void> => {
const templateDir = paths.resolveOwn('templates/default-app');
const tempDir = resolvePath(os.tmpdir(), answers.name);
// Use `--path` argument as applicaiton directory when specified, otherwise
// Use `--path` argument as application directory when specified, otherwise
// create a directory using `answers.name`
const appDir = cmd.path
? resolvePath(paths.targetDir, cmd.path)
@@ -77,9 +77,7 @@ auth:
providers: {}
scaffolder:
github:
token: ${GITHUB_TOKEN}
visibility: public # or 'internal' or 'private'
# see https://backstage.io/docs/features/software-templates/configuration for software template options
catalog:
rules:
@@ -31,7 +31,7 @@
},
"devDependencies": {
"@backstage/cli": "^{{version '@backstage/cli'}}",
"@spotify/prettier-config": "^11.0.0",
"@spotify/prettier-config": "^12.0.0",
"concurrently": "^6.0.0",
"lerna": "^4.0.0",
"prettier": "^2.3.2"
@@ -22,7 +22,6 @@
"@backstage/plugin-tech-radar": "^{{version '@backstage/plugin-tech-radar'}}",
"@backstage/plugin-techdocs": "^{{version '@backstage/plugin-techdocs'}}",
"@backstage/plugin-user-settings": "^{{version '@backstage/plugin-user-settings'}}",
"@backstage/test-utils": "^{{version '@backstage/test-utils'}}",
"@backstage/theme": "^{{version '@backstage/theme'}}",
"@material-ui/core": "^4.12.2",
"@material-ui/icons": "^4.9.1",
@@ -34,6 +33,7 @@
"react-use": "^15.3.3"
},
"devDependencies": {
"@backstage/test-utils": "^{{version '@backstage/test-utils'}}",
"@testing-library/jest-dom": "^5.10.1",
"@testing-library/react": "^10.4.1",
"@testing-library/user-event": "^12.0.7",
@@ -48,11 +48,11 @@
"scripts": {
"start": "backstage-cli app:serve",
"build": "backstage-cli app:build",
"test": "backstage-cli test",
"lint": "backstage-cli lint",
"clean": "backstage-cli clean",
"test": "backstage-cli test",
"test:e2e": "cross-env PORT=3001 start-server-and-test start http://localhost:3001 cy:dev",
"test:e2e:ci": "cross-env PORT=3001 start-server-and-test start http://localhost:3001 cy:run",
"lint": "backstage-cli lint",
"cy:dev": "cypress open",
"cy:run": "cypress run"
},
+5 -7
View File
@@ -44,11 +44,9 @@ export type DevAppPageOptions = {
};
// @public (undocumented)
export const EntityGridItem: ({
entity,
classes,
...rest
}: Omit<GridProps<'div', {}>, 'container' | 'item'> & {
entity: Entity;
}) => JSX.Element;
export const EntityGridItem: (
props: Omit<GridProps, 'item' | 'container'> & {
entity: Entity;
},
) => JSX.Element;
```
+5 -3
View File
@@ -43,15 +43,17 @@
"@testing-library/jest-dom": "^5.10.1",
"@testing-library/react": "^11.2.5",
"@testing-library/user-event": "^13.1.8",
"@types/react": "*",
"react": "^16.12.0",
"react-use": "^17.2.4",
"react-dom": "^16.12.0",
"react-hot-loader": "^4.12.21",
"react-router": "6.0.0-beta.0",
"react-router-dom": "6.0.0-beta.0",
"zen-observable": "^0.8.15"
},
"peerDependencies": {
"@types/react": "^16.13.1 || ^17.0.0",
"react": "^16.13.1 || ^17.0.0",
"react-dom": "^16.13.1 || ^17.0.0"
},
"devDependencies": {
"@backstage/cli": "^0.10.0",
"@types/jest": "^26.0.7",
@@ -35,11 +35,10 @@ const useStyles = makeStyles<BackstageTheme, { entity: Entity }>(theme => ({
}));
/** @public */
export const EntityGridItem = ({
entity,
classes,
...rest
}: Omit<GridProps, 'item' | 'container'> & { entity: Entity }): JSX.Element => {
export const EntityGridItem = (
props: Omit<GridProps, 'item' | 'container'> & { entity: Entity },
): JSX.Element => {
const { entity, classes, ...rest } = props;
const itemClasses = useStyles({ entity });
return (
+3 -2
View File
@@ -29,10 +29,11 @@
"@material-ui/core": "^4.12.2",
"@material-ui/icons": "^4.9.1",
"@material-ui/lab": "4.0.0-alpha.57",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-use": "^17.2.4"
},
"peerDependencies": {
"react": "^16.13.1 || ^17.0.0"
},
"devDependencies": {
"@backstage/cli": "^0.10.0",
"@backstage/dev-utils": "^0.2.13",
+2 -2
View File
@@ -9,8 +9,8 @@
},
"dependencies": {
"@backstage/theme": "^0.2.0",
"react": "^16.12.0",
"react-dom": "^16.12.0"
"react": "^16.13.1",
"react-dom": "^16.13.1"
},
"devDependencies": {
"@storybook/addon-a11y": "^6.3.4",
+10 -44
View File
@@ -49,22 +49,6 @@ export type GeneratorBuilder = {
get(entity: Entity): GeneratorBase;
};
// Warning: (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
// Warning: (tsdoc-param-tag-with-invalid-type) The @param block should not include a JSDoc-style '{type}'
// Warning: (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
// Warning: (tsdoc-param-tag-with-invalid-type) The @param block should not include a JSDoc-style '{type}'
// Warning: (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
// Warning: (tsdoc-param-tag-with-invalid-type) The @param block should not include a JSDoc-style '{type}'
// Warning: (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
// Warning: (tsdoc-param-tag-with-invalid-type) The @param block should not include a JSDoc-style '{type}'
// Warning: (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
// Warning: (tsdoc-param-tag-with-invalid-optional-name) The @param should not include a JSDoc-style optional name; it must not be enclosed in '[ ]' brackets.
// Warning: (tsdoc-param-tag-with-invalid-type) The @param block should not include a JSDoc-style '{type}'
// Warning: (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
// Warning: (tsdoc-param-tag-with-invalid-optional-name) The @param should not include a JSDoc-style optional name; it must not be enclosed in '[ ]' brackets.
// Warning: (tsdoc-param-tag-with-invalid-type) The @param block should not include a JSDoc-style '{type}'
// Warning: (ae-missing-release-tag) "GeneratorRunOptions" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public
export type GeneratorRunOptions = {
inputDir: string;
@@ -82,10 +66,7 @@ export class Generators implements GeneratorBuilder {
// (undocumented)
static fromConfig(
config: Config,
{
logger,
containerRunner,
}: {
options: {
logger: Logger_2;
containerRunner: ContainerRunner;
},
@@ -185,13 +166,10 @@ export class Publisher {
): Promise<PublisherBase>;
}
// Warning: (ae-missing-release-tag) "PublisherBase" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public
export interface PublisherBase {
docsRouter(): express.Handler;
fetchTechDocsMetadata(entityName: EntityName): Promise<TechDocsMetadata>;
// Warning: (ae-forgotten-export) The symbol "ReadinessResponse" needs to be exported by the entry point index.d.ts
getReadiness(): Promise<ReadinessResponse>;
hasDocsBeenGenerated(entityName: Entity): Promise<boolean>;
// Warning: (tsdoc-escape-right-brace) The "}" character should be escaped using a backslash to avoid confusion with a TSDoc inline tag
@@ -202,7 +180,6 @@ export interface PublisherBase {
// Warning: (tsdoc-malformed-inline-tag) Expecting a TSDoc tag starting with "{@"
// Warning: (ae-forgotten-export) The symbol "MigrateRequest" needs to be exported by the entry point index.d.ts
migrateDocsCase?(migrateRequest: MigrateRequest): Promise<void>;
// Warning: (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
// Warning: (ae-forgotten-export) The symbol "PublishRequest" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "PublishResponse" needs to be exported by the entry point index.d.ts
publish(request: PublishRequest): Promise<PublishResponse>;
@@ -218,6 +195,11 @@ export type PublisherType =
| 'azureBlobStorage'
| 'openStackSwift';
// @public
export type ReadinessResponse = {
isAvailable: boolean;
};
// Warning: (ae-missing-release-tag) "RemoteProtocol" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
@@ -245,12 +227,7 @@ export interface TechDocsDocument extends IndexableDocument {
//
// @public (undocumented)
export class TechdocsGenerator implements GeneratorBase {
constructor({
logger,
containerRunner,
config,
scmIntegrations,
}: {
constructor(options: {
logger: Logger_2;
containerRunner: ContainerRunner;
config: Config;
@@ -260,26 +237,15 @@ export class TechdocsGenerator implements GeneratorBase {
// (undocumented)
static fromConfig(
config: Config,
{
containerRunner,
logger,
}: {
options: {
containerRunner: ContainerRunner;
logger: Logger_2;
},
): TechdocsGenerator;
// (undocumented)
run({
inputDir,
outputDir,
parsedLocationAnnotation,
etag,
logger: childLogger,
logStream,
}: GeneratorRunOptions): Promise<void>;
run(options: GeneratorRunOptions): Promise<void>;
}
// Warning: (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
// Warning: (ae-missing-release-tag) "TechDocsMetadata" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public
@@ -319,7 +285,7 @@ export class UrlPreparer implements PreparerBase {
// Warnings were encountered during analysis:
//
// src/stages/generate/types.d.ts:44:5 - (ae-forgotten-export) The symbol "SupportedGeneratorKey" needs to be exported by the entry point index.d.ts
// src/stages/generate/types.d.ts:45:5 - (ae-forgotten-export) The symbol "SupportedGeneratorKey" needs to be exported by the entry point index.d.ts
// src/stages/prepare/types.d.ts:18:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
// src/stages/prepare/types.d.ts:19:8 - (tsdoc-param-tag-with-invalid-name) The @param block should be followed by a valid parameter name: The identifier cannot non-word characters
// src/stages/prepare/types.d.ts:21:33 - (tsdoc-escape-right-brace) The "}" character should be escaped using a backslash to avoid confusion with a TSDoc inline tag
@@ -31,17 +31,11 @@ export class Generators implements GeneratorBuilder {
static async fromConfig(
config: Config,
{
logger,
containerRunner,
}: { logger: Logger; containerRunner: ContainerRunner },
options: { logger: Logger; containerRunner: ContainerRunner },
): Promise<GeneratorBuilder> {
const generators = new Generators();
const techdocsGenerator = TechdocsGenerator.fromConfig(config, {
logger,
containerRunner,
});
const techdocsGenerator = TechdocsGenerator.fromConfig(config, options);
generators.register('techdocs', techdocsGenerator);
return generators;
@@ -384,7 +384,7 @@ export const createOrUpdateMetadata = async (
// a form appropriate for invalidating the associated object from cache.
try {
json.files = (await getFileTreeRecursively(techdocsMetadataDir)).map(file =>
file.replace(`${techdocsMetadataDir}/`, ''),
file.replace(`${techdocsMetadataDir}${path.sep}`, ''),
);
} catch (err) {
assertError(err);
@@ -52,11 +52,9 @@ export class TechdocsGenerator implements GeneratorBase {
static fromConfig(
config: Config,
{
containerRunner,
logger,
}: { containerRunner: ContainerRunner; logger: Logger },
options: { containerRunner: ContainerRunner; logger: Logger },
) {
const { containerRunner, logger } = options;
const scmIntegrations = ScmIntegrations.fromConfig(config);
return new TechdocsGenerator({
logger,
@@ -66,31 +64,28 @@ export class TechdocsGenerator implements GeneratorBase {
});
}
constructor({
logger,
containerRunner,
config,
scmIntegrations,
}: {
constructor(options: {
logger: Logger;
containerRunner: ContainerRunner;
config: Config;
scmIntegrations: ScmIntegrationRegistry;
}) {
this.logger = logger;
this.options = readGeneratorConfig(config, logger);
this.containerRunner = containerRunner;
this.scmIntegrations = scmIntegrations;
this.logger = options.logger;
this.options = readGeneratorConfig(options.config, options.logger);
this.containerRunner = options.containerRunner;
this.scmIntegrations = options.scmIntegrations;
}
public async run({
inputDir,
outputDir,
parsedLocationAnnotation,
etag,
logger: childLogger,
logStream,
}: GeneratorRunOptions): Promise<void> {
public async run(options: GeneratorRunOptions): Promise<void> {
const {
inputDir,
outputDir,
parsedLocationAnnotation,
etag,
logger: childLogger,
logStream,
} = options;
// Do some updates to mkdocs.yml before generating docs e.g. adding repo_url
const { path: mkdocsYmlPath, content } = await getMkdocsYml(inputDir);
@@ -34,12 +34,13 @@ export type GeneratorConfig = {
/**
* The values that the generator will receive.
*
* @param {string} inputDir The directory of the uncompiled documentation, with the values from the frontend
* @param {string} outputDir Directory to store generated docs in. Usually - a newly created temporary directory.
* @param {ParsedLocationAnnotation} parsedLocationAnnotation backstage.io/techdocs-ref annotation of an entity
* @param {string} etag A unique identifier for the prepared tree e.g. commit SHA. If provided it will be stored in techdocs_metadata.json.
* @param {Logger} [logger] A logger that forwards the messages to the caller to be displayed outside of the backend.
* @param {Writable} [logStream] A log stream that can send raw log messages to the caller to be displayed outside of the backend..
* @public
* @param inputDir - The directory of the uncompiled documentation, with the values from the frontend
* @param outputDir - Directory to store generated docs in. Usually - a newly created temporary directory.
* @param parsedLocationAnnotation - backstage.io/techdocs-ref annotation of an entity
* @param etag - A unique identifier for the prepared tree e.g. commit SHA. If provided it will be stored in techdocs_metadata.json.
* @param logger - A logger that forwards the messages to the caller to be displayed outside of the backend.
* @param logStream - A log stream that can send raw log messages to the caller to be displayed outside of the backend.
*/
export type GeneratorRunOptions = {
inputDir: string;
@@ -14,4 +14,9 @@
* limitations under the License.
*/
export { Publisher } from './publish';
export type { PublisherBase, PublisherType, TechDocsMetadata } from './types';
export type {
PublisherBase,
PublisherType,
TechDocsMetadata,
ReadinessResponse,
} from './types';
@@ -51,6 +51,8 @@ export type PublishResponse = {
/**
* Result for the validation check.
*
* @public
*/
export type ReadinessResponse = {
/** If true, the publisher is able to interact with the backing storage. */
@@ -59,7 +61,7 @@ export type ReadinessResponse = {
/**
* Type to hold metadata found in techdocs_metadata.json and associated with each site
* @param etag ETag of the resource used to generate the site. Usually the latest commit sha of the source repository.
* @param etag - ETag of the resource used to generate the site. Usually the latest commit sha of the source repository.
*/
export type TechDocsMetadata = {
site_name: string;
@@ -86,6 +88,8 @@ export type MigrateRequest = {
* Base class for a TechDocs publisher (e.g. Local, Google GCS Bucket, AWS S3, etc.)
* The publisher handles publishing of the generated static files after the prepare and generate steps of TechDocs.
* It also provides APIs to communicate with the storage service.
*
* @public
*/
export interface PublisherBase {
/**
@@ -99,8 +103,8 @@ export interface PublisherBase {
/**
* Store the generated static files onto a storage service (either local filesystem or external service).
*
* @param request Object containing the entity from the service
* catalog, and the directory that contains the generated static files from TechDocs.
* @param request - Object containing the entity from the service
* catalog, and the directory that contains the generated static files from TechDocs.
*/
publish(request: PublishRequest): Promise<PublishResponse>;
+5 -16
View File
@@ -89,23 +89,13 @@ export type LogFuncs = 'log' | 'warn' | 'error';
// @public
export class MockAnalyticsApi implements AnalyticsApi {
// (undocumented)
captureEvent({
action,
subject,
value,
attributes,
context,
}: AnalyticsEvent): void;
captureEvent(event: AnalyticsEvent): void;
// (undocumented)
getEvents(): AnalyticsEvent[];
}
// @public
export function mockBreakpoint({
matches,
}: {
matches?: boolean | undefined;
}): void;
export function mockBreakpoint(options: { matches: boolean }): void;
// @public
export class MockErrorApi implements ErrorApi {
@@ -178,10 +168,9 @@ export function setupRequestMockHandlers(worker: {
export type SyncLogCollector = () => void;
// @public
export const TestApiProvider: <T extends any[]>({
apis,
children,
}: TestApiProviderProps<T>) => JSX.Element;
export const TestApiProvider: <T extends any[]>(
props: TestApiProviderProps<T>,
) => JSX.Element;
// @public
export type TestApiProviderProps<TApiPairs extends any[]> = {
+4 -3
View File
@@ -38,13 +38,14 @@
"@testing-library/jest-dom": "^5.10.1",
"@testing-library/react": "^11.2.5",
"@testing-library/user-event": "^13.1.8",
"@types/react": "*",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react-router": "6.0.0-beta.0",
"react-router-dom": "6.0.0-beta.0",
"zen-observable": "^0.8.15"
},
"peerDependencies": {
"@types/react": "^16.13.1 || ^17.0.0",
"react": "^16.13.1 || ^17.0.0"
},
"devDependencies": {
"@backstage/cli": "^0.10.0",
"@types/jest": "^26.0.7",
@@ -120,11 +120,13 @@ export class TestApiRegistry implements ApiHolder {
*
* @public
**/
export const TestApiProvider = <T extends any[]>({
apis,
children,
}: TestApiProviderProps<T>) => {
export const TestApiProvider = <T extends any[]>(
props: TestApiProviderProps<T>,
) => {
return (
<ApiProvider apis={TestApiRegistry.from(...apis)} children={children} />
<ApiProvider
apis={TestApiRegistry.from(...props.apis)}
children={props.children}
/>
);
};
@@ -19,18 +19,15 @@ import { AnalyticsApi, AnalyticsEvent } from '@backstage/core-plugin-api';
/**
* Mock implementation of {@link core-plugin-api#AnalyticsApi} with helpers to ensure that events are sent correctly.
* Use getEvents in tests to verify captured events.
*
* @public
*/
export class MockAnalyticsApi implements AnalyticsApi {
private events: AnalyticsEvent[] = [];
captureEvent({
action,
subject,
value,
attributes,
context,
}: AnalyticsEvent) {
captureEvent(event: AnalyticsEvent) {
const { action, subject, value, attributes, context } = event;
this.events.push({
action,
subject,
@@ -15,8 +15,8 @@
*/
/**
* This is a mocking method suggested in the Jest Doc's, as it is not implemented in JSDOM yet.
* It can be used to mock values when the MUI `useMediaQuery` hook if it is used in a tested component.
* This is a mocking method suggested in the Jest docs, as it is not implemented in JSDOM yet.
* It can be used to mock values for the MUI `useMediaQuery` hook if it is used in a tested component.
*
* For issues checkout the documentation:
* https://jestjs.io/docs/manual-mocks#mocking-methods-which-are-not-implemented-in-jsdom
@@ -26,11 +26,11 @@
*
* @public
*/
export default function mockBreakpoint({ matches = false }) {
export default function mockBreakpoint(options: { matches: boolean }) {
Object.defineProperty(window, 'matchMedia', {
writable: true,
value: jest.fn().mockImplementation(query => ({
matches: matches,
matches: options.matches ?? false,
media: query,
onchange: null,
addListener: jest.fn(), // deprecated
@@ -15,8 +15,7 @@
*/
import { ReactElement } from 'react';
import { act } from 'react-dom/test-utils';
import { render, RenderResult } from '@testing-library/react';
import { act, render, RenderResult } from '@testing-library/react';
/**
* @public
+3 -3
View File
@@ -28,9 +28,9 @@
"postpack": "backstage-cli postpack",
"clean": "backstage-cli clean"
},
"dependencies": {
"@types/react": "*",
"react": "^16.12.0"
"peerDependencies": {
"@types/react": "^16.13.1 || ^17.0.0",
"react": "^16.13.1 || ^17.0.0"
},
"devDependencies": {
"@backstage/cli": "^0.10.0",