chore: fixing last of the typescripts
This commit is contained in:
@@ -57,7 +57,7 @@ That type looks like the following:
|
||||
export type PublisherBase = {
|
||||
publish(opts: {
|
||||
entity: TemplateEntityV1alpha1;
|
||||
values: RequiredTemplateValues & Record<string, JsonValue>;
|
||||
values: TemplaterValues;
|
||||
directory: string;
|
||||
}): Promise<{ remoteUrl: string }>;
|
||||
};
|
||||
|
||||
@@ -61,7 +61,7 @@ That type looks like the following:
|
||||
```ts
|
||||
export type TemplaterRunOptions = {
|
||||
directory: string;
|
||||
values: RequiredTemplateValues & Record<string, JsonValue>;
|
||||
values: TemplaterValues;
|
||||
logStream?: Writable;
|
||||
dockerClient: Docker;
|
||||
};
|
||||
|
||||
@@ -17,6 +17,7 @@ import { JobProcessor } from './processor';
|
||||
import { TemplateEntityV1alpha1 } from '@backstage/catalog-model';
|
||||
import { StageInput } from './types';
|
||||
import { RequiredTemplateValues } from '../stages/templater';
|
||||
import parseGitUrl from 'git-url-parse';
|
||||
|
||||
describe('JobProcessor', () => {
|
||||
const mockEntity: TemplateEntityV1alpha1 = {
|
||||
@@ -61,7 +62,10 @@ describe('JobProcessor', () => {
|
||||
|
||||
const mockValues: RequiredTemplateValues = {
|
||||
owner: 'blobby',
|
||||
storePath: 'backstage/mock-repo',
|
||||
storePath: 'https://github.com/backstage/mock-repo',
|
||||
destination: {
|
||||
git: parseGitUrl('https://github.com/backstage/mock-repo'),
|
||||
},
|
||||
};
|
||||
|
||||
describe('create', () => {
|
||||
|
||||
@@ -14,11 +14,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { Processor, Job, StageContext, StageInput } from './types';
|
||||
import { JsonValue } from '@backstage/config';
|
||||
import { TemplateEntityV1alpha1 } from '@backstage/catalog-model';
|
||||
import * as uuid from 'uuid';
|
||||
import Docker from 'dockerode';
|
||||
import { RequiredTemplateValues, TemplaterBase } from '../stages/templater';
|
||||
import { TemplaterValues, TemplaterBase } from '../stages/templater';
|
||||
import { PreparerBuilder } from '../stages/prepare';
|
||||
import { makeLogStream } from './logger';
|
||||
|
||||
@@ -42,7 +41,7 @@ export class JobProcessor implements Processor {
|
||||
stages,
|
||||
}: {
|
||||
entity: TemplateEntityV1alpha1;
|
||||
values: RequiredTemplateValues & Record<string, JsonValue>;
|
||||
values: TemplaterValues;
|
||||
stages: StageInput[];
|
||||
}): Job {
|
||||
const id = uuid.v4();
|
||||
|
||||
@@ -15,15 +15,14 @@
|
||||
*/
|
||||
import type { Writable } from 'stream';
|
||||
import { TemplateEntityV1alpha1 } from '@backstage/catalog-model';
|
||||
import { JsonValue } from '@backstage/config';
|
||||
import { RequiredTemplateValues } from '../stages/templater';
|
||||
import { TemplaterValues } from '../stages/templater';
|
||||
import { Logger } from 'winston';
|
||||
|
||||
// Context will be a mutable object which is passed between stages
|
||||
// To share data, but also thinking that we can pass in functions here too
|
||||
// To maybe create sub steps or fail the entire thing, or skip stages down the line.
|
||||
export type StageContext<T = {}> = {
|
||||
values: RequiredTemplateValues & Record<string, JsonValue>;
|
||||
values: TemplaterValues;
|
||||
entity: TemplateEntityV1alpha1;
|
||||
logger: Logger;
|
||||
logStream: Writable;
|
||||
@@ -58,7 +57,7 @@ export type Processor = {
|
||||
stages,
|
||||
}: {
|
||||
entity: TemplateEntityV1alpha1;
|
||||
values: RequiredTemplateValues & Record<string, JsonValue>;
|
||||
values: TemplaterValues;
|
||||
stages: StageInput[];
|
||||
}): Job;
|
||||
|
||||
|
||||
@@ -13,8 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { RequiredTemplateValues } from '../templater';
|
||||
import { JsonValue } from '@backstage/config';
|
||||
import { TemplaterValues } from '../templater';
|
||||
import { Logger } from 'winston';
|
||||
|
||||
/**
|
||||
@@ -32,7 +31,7 @@ export type PublisherBase = {
|
||||
};
|
||||
|
||||
export type PublisherOptions = {
|
||||
values: RequiredTemplateValues & Record<string, JsonValue>;
|
||||
values: TemplaterValues;
|
||||
directory: string;
|
||||
logger: Logger;
|
||||
};
|
||||
|
||||
@@ -72,7 +72,7 @@ export class CreateReactAppTemplater implements TemplaterBase {
|
||||
|
||||
extraAnnotations[
|
||||
GITHUB_ACTIONS_ANNOTATION
|
||||
] = `${options.values.destination.git.owner}/${options.values.destination.git.name}`;
|
||||
] = `${options.values?.destination?.git?.owner}/${options.values?.destination?.git?.name}`;
|
||||
}
|
||||
|
||||
const componentInfo = {
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
import type { Writable } from 'stream';
|
||||
import Docker from 'dockerode';
|
||||
import { JsonValue } from '@backstage/config';
|
||||
import { TemplateEntityV1alpha1 } from '@backstage/catalog-model';
|
||||
import gitUrlParse from 'git-url-parse';
|
||||
|
||||
@@ -26,11 +25,13 @@ import gitUrlParse from 'git-url-parse';
|
||||
export type RequiredTemplateValues = {
|
||||
owner: string;
|
||||
storePath: string;
|
||||
destination: {
|
||||
git: gitUrlParse.GitUrl;
|
||||
destination?: {
|
||||
git?: gitUrlParse.GitUrl;
|
||||
};
|
||||
};
|
||||
|
||||
export type TemplaterValues = RequiredTemplateValues & Record<string, any>;
|
||||
|
||||
/**
|
||||
* The returned directory from the templater which is ready
|
||||
* to pass to the next stage of the scaffolder which is publishing
|
||||
@@ -46,7 +47,7 @@ export type TemplaterRunResult = {
|
||||
*/
|
||||
export type TemplaterRunOptions = {
|
||||
directory: string;
|
||||
values: RequiredTemplateValues & Record<string, any>;
|
||||
values: TemplaterValues;
|
||||
logStream?: Writable;
|
||||
dockerClient: Docker;
|
||||
};
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Config, JsonValue } from '@backstage/config';
|
||||
import { Config } from '@backstage/config';
|
||||
import fs from 'fs-extra';
|
||||
import Docker from 'dockerode';
|
||||
import express from 'express';
|
||||
@@ -23,9 +23,9 @@ import { Logger } from 'winston';
|
||||
import {
|
||||
JobProcessor,
|
||||
PreparerBuilder,
|
||||
RequiredTemplateValues,
|
||||
StageContext,
|
||||
TemplaterBuilder,
|
||||
TemplaterValues,
|
||||
PublisherBuilder,
|
||||
parseLocationAnnotation,
|
||||
FilePreparer,
|
||||
@@ -110,13 +110,12 @@ export async function createRouter(
|
||||
})
|
||||
.post('/v1/jobs', async (req, res) => {
|
||||
const templateName: string = req.body.templateName;
|
||||
const values: RequiredTemplateValues & Record<string, JsonValue> = {
|
||||
const values: TemplaterValues = {
|
||||
...req.body.values,
|
||||
destination: {
|
||||
git: parseGitUrl(req.body.values.storePath),
|
||||
},
|
||||
};
|
||||
req.body.values;
|
||||
|
||||
const template = await entityClient.findTemplate(templateName);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user