@frontside/backstage-plugin-scaffolder-workflow

中文文档
0.10.2发布于 2024/08/14Apache-2.0TypeScriptCommonJS近 30 天下载 2411

Scaffolder workflows are one of the focal points of backstage that alleviates the pain of writing boilerplate code for almost any situation.

原始使用文档
文档目录4 节
  1. Why?
  2. Getting started
  3. Hooks
  4. Components

@frontside/backstage-plugin-scaffolder-workflow

Why?

Scaffolder workflows are one of the focal points of backstage that alleviates the pain of writing boilerplate code for almost any situation.

Running scaffolder workflows outside of their current backstage location is impossible, and we would like to run scaffolder workflows in just about any react component in a backstage instance.

This repo provides the building blocks to do just that and components that enable scaffolder workflows to run in different scenarios.

Getting started

# npm
npm install @backstage/plugin-scaffolder-react

# yarn
yarn add @backstage/plugin-scaffolder-react

#pnpm
pnpm add @backstage/plugin-scaffolder-react

Hooks

useRunWorkflow - Kicks off a scaffolder workflow, and it returns a taskStream of workflow events

const templateRef = stringifyEntityRef({
  kind: 'Template',
  namespace: 'default',
  name: 'update-system',
});

const { taskStatus, execute, taskStream } = useRunWorkflow({
  templateRef,
  onComplete,
  onError,
});

useStepper - Keep track of the workflow steps outside of a component instance:

  const templateRef = stringifyEntityRef({
    kind: 'Template',
    namespace: 'default',
    name: 'update-system',
  });

  const { loading, manifest } = useTemplateParameterSchema(templateRef);

const { currentStep } = useStepper({ manifest });

Components

ModalWorkflow - Kick off a scaffolder workflow by clicking a link and running the workflow form in a modal:

demo

<>
  {entity?.spec?.system ? entity.spec.system : 'System not specified.'}
  <Tooltip title="Assign System">
    <IconButton aria-label="Assign System" color="primary" onClick={() => setOpen(true)}>
      <SystemUpdateIcon />
    </IconButton>
  </Tooltip>
  <ModalWorkflow
    open={open}
    onClick={() => {}}
    onClose={closeHandler}
    onCreate={onCreate}
    namespace="default"
    templateName="update-system"
    initialState={{ url, entityRef, system: entity?.spec?.system ?? '' }}
    onError={(_e) => {
      // eslint-disable-next-line no-console
      console.log('optional error handler')
    }}
  >
    <ScaffolderFieldExtensions>
      <EntityPickerFieldExtension />
    </ScaffolderFieldExtensions>
    <Button
      variant="contained"
      color="primary"
      type="submit"
      onClick={onCreate as any}
    >
      Link
    </Button>
  </ModalWorkflow>
</>

WorkflowButton - If there are no form elements or no user input is required, then a scaffolder workflow can be executed via a simple button click and the button has props to display state change messaging:

demo

<WorkflowButton
  namespace="default"
  templateName="deprecate-component"
  components={{
    idle: <Idle initialState={{ url, entityRef }} />,
    pending: <Pending />,
    error: <Error />,
    success: <Success />,
    modal: <Modal />,
  }}
/>

EmbeddedScaffolderWorkflow - A lot like the traditional scaffolder workflow only it is a regular component that can be added to different place in the backstage instance.

export function EntityOnboardingWorkflow(
  props: EntityOnboardingWorkflowProps,
): JSX.Element | null {
  const { entity } = useEntity();

  const entityRef = stringifyEntityRef(entity);

  const catalogInfoUrl = entity.metadata?.annotations?.[
    ANNOTATION_ORIGIN_LOCATION
  ].replace(/^url:/, '');

  assert(
    !!catalogInfoUrl,
    `no catalog-info.yaml url in ${ANNOTATION_ORIGIN_LOCATION} annotation`,
  );

  return (
    <EmbeddedScaffolderWorkflow
      {...props}
      initialState={{ catalogInfoUrl, entityRef }}
    />
  );
}

版本与发布记录

@frontside/backstage-plugin-scaffolder-workflow 共发布 31 个版本,首次发布于 2023/02/03;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.10.2latest2024/08/142 年前
0.10.2-dl-update-deps.1dl-update-deps2024/08/012 年前
0.10.2-dl-update-deps.02024/07/302 年前
0.10.2-tm-upgrade-backstage-1.25.0tm-upgrade-backstage-1.252024/04/232 年前
0.10.12024/03/202 年前
0.10.2-changeset-release-main.0changeset-release-main2024/03/202 年前

其他发布通道:taras-patch-1 → 0.2.3-taras-patch-1.0,dl-update-backstage → 0.10.1-dl-update-backstage.2,changeset-release-main → 0.10.2-changeset-release-main.0,tm-upgrade-backstage-1.25 → 0.10.2-tm-upgrade-backstage-1.25.0,dl-update-deps → 0.10.2-dl-update-deps.1。

关于 @frontside/backstage-plugin-scaffolder-workflow 的常见问题

@frontside/backstage-plugin-scaffolder-workflow 是什么?

Scaffolder workflows are one of the focal points of backstage that alleviates the pain of writing boilerplate code for almost any situation.

如何安装 @frontside/backstage-plugin-scaffolder-workflow?

在项目目录运行 npm install @frontside/backstage-plugin-scaffolder-workflow,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(^16.13.1 || ^17.0.0)、react-router-dom(^6.x.x)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@frontside/backstage-plugin-scaffolder-workflow 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@frontside/backstage-plugin-scaffolder-workflow 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@frontside/backstage-plugin-scaffolder-workflow 可以商用吗?

@frontside/backstage-plugin-scaffolder-workflow 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@frontside/backstage-plugin-scaffolder-workflow 的下载量有多少?

根据 npm 官方下载统计,@frontside/backstage-plugin-scaffolder-workflow 在 2026/10/16 – 2026/11/14 这 30 天内被下载 2,411 次,日均约 80 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@frontside/backstage-plugin-scaffolder-workflow 还在维护吗?

最新版本 0.10.2 发布于 2024/08/14(2 年前);至今共发布 31 个版本,其中过去 12 个月发布了 0 个;首次发布于 2023/02/03。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。