johnson-jesse / simple-backstage-app

Using Backstage.io to create a monorepo, standalone app
4 stars 1 forks source link

many compilation errors with current release of backstage packages #1

Open n2ygk opened 3 years ago

n2ygk commented 3 years ago

Summary & Context

You're probably aware of this, but since this repo is referenced in the backstage.io tutorials documentation, I thought I'd point out that there are a number of compilation errors after bumping versions. I ran into this when I was trying to follow steps to build my own starting with create-app and used this example for, e.g. apis.ts which caused this compile error:

$ tsc
packages/app/src/App.tsx:32:3 - error TS2741: Property '[Symbol.iterator]' is missing in type '(config: ConfigApi) => ApiRegistry' but required in type 'Iterable<ApiFactory<unknown, unknown, { [x: string]: unknown; }>>'.

32   apis,
     ~~~~

  node_modules/typescript/lib/lib.es2015.iterable.d.ts:51:5
    51     [Symbol.iterator](): Iterator<T>;
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    '[Symbol.iterator]' is declared here.

Found 1 error.

error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

So I'm wondering if this repo should even be referenced anymore, and if so, needs updating, or just point people at the example app in the backstage.io repo?

Steps to reproduce:

Edit package.json to upgrade backstage-cli to add the versions:bump command (and allow node 14):

diff --git a/package.json b/package.json
index 035056e..4a0f185 100644
--- a/package.json
+++ b/package.json
@@ -3,7 +3,7 @@
   "version": "1.0.0",
   "private": true,
   "engines": {
-    "node": "12"
+    "node": "12 || 14"
   },
   "scripts": {
     "start": "yarn workspace app start",
@@ -25,7 +25,7 @@
     ]
   },
   "devDependencies": {
-    "@backstage/cli": "^0.1.1-alpha.21",
+    "@backstage/cli": "0.4.2",
     "@spotify/prettier-config": "^7.0.0",
     "lerna": "^3.20.2",
     "prettier": "^1.19.1"

yarn install to install it and then yarn backstage-cli versions:bump

This results in a bunch of updated packages:

simple-backstage-app$ git diff packages/
diff --git a/packages/app/package.json b/packages/app/package.json
index 78edde4..e785451 100644
--- a/packages/app/package.json
+++ b/packages/app/package.json
@@ -6,19 +6,19 @@
   "dependencies": {
     "@material-ui/core": "^4.9.1",
     "@material-ui/icons": "^4.9.1",
-    "@backstage/cli": "^0.1.1-alpha.21",
-    "@backstage/core": "^0.1.1-alpha.21",
-    "@backstage/plugin-catalog": "^0.1.1-alpha.21",
-    "@backstage/plugin-register-component": "^0.1.1-alpha.21",
-    "@backstage/plugin-scaffolder": "^0.1.1-alpha.21",
-    "@backstage/plugin-techdocs": "^0.1.1-alpha.21",
-    "@backstage/plugin-circleci": "^0.1.1-alpha.21",
-    "@backstage/plugin-explore": "^0.1.1-alpha.21",
-    "@backstage/plugin-lighthouse": "^0.1.1-alpha.21",
-    "@backstage/plugin-tech-radar": "^0.1.1-alpha.21",
-    "@backstage/plugin-github-actions": "^0.1.1-alpha.21",
+    "@backstage/cli": "^0.4.2",
+    "@backstage/core": "^0.4.1",
+    "@backstage/plugin-catalog": "^0.2.7",
+    "@backstage/plugin-register-component": "^0.2.5",
+    "@backstage/plugin-scaffolder": "^0.3.4",
+    "@backstage/plugin-techdocs": "^0.5.0",
+    "@backstage/plugin-circleci": "^0.2.5",
+    "@backstage/plugin-explore": "^0.2.2",
+    "@backstage/plugin-lighthouse": "^0.2.6",
+    "@backstage/plugin-tech-radar": "^0.3.1",
+    "@backstage/plugin-github-actions": "^0.2.5",
     "@backstage/test-utils": "^0.1.1-alpha.21",
-    "@backstage/theme": "^0.1.1-alpha.21",
+    "@backstage/theme": "^0.2.2",
     "history": "^5.0.0",
     "react": "^16.13.1",
     "react-dom": "^16.13.1",
diff --git a/packages/backend/package.json b/packages/backend/package.json
index 193f5c9..08df626 100644
--- a/packages/backend/package.json
+++ b/packages/backend/package.json
@@ -17,16 +17,16 @@
     "migrate:create": "knex migrate:make -x ts"
   },
   "dependencies": {
-    "@backstage/backend-common": "^0.1.1-alpha.21",
-    "@backstage/catalog-model": "^0.1.1-alpha.21",
+    "@backstage/backend-common": "^0.4.1",
+    "@backstage/catalog-model": "^0.6.0",
     "@backstage/config": "^0.1.1-alpha.21",
-    "@backstage/plugin-auth-backend": "^0.1.1-alpha.21",
-    "@backstage/plugin-catalog-backend": "^0.1.1-alpha.21",
+    "@backstage/plugin-auth-backend": "^0.2.7",
+    "@backstage/plugin-catalog-backend": "^0.5.0",
     "@backstage/plugin-identity-backend": "^0.1.1-alpha.21",
-    "@backstage/plugin-proxy-backend": "^0.1.1-alpha.21",
+    "@backstage/plugin-proxy-backend": "^0.2.3",
     "@backstage/plugin-rollbar-backend": "^0.1.1-alpha.21",
-    "@backstage/plugin-scaffolder-backend": "^0.1.1-alpha.21",
-    "@backstage/plugin-techdocs-backend": "^0.1.1-alpha.21",
+    "@backstage/plugin-scaffolder-backend": "^0.3.5",
+    "@backstage/plugin-techdocs-backend": "^0.4.0",
     "@octokit/rest": "^18.0.0",
     "dockerode": "^3.2.0",
     "express": "^4.17.1",
@@ -35,7 +35,7 @@
     "winston": "^3.2.1"
   },
   "devDependencies": {
-    "@backstage/cli": "^0.1.1-alpha.21",
+    "@backstage/cli": "^0.4.2",
     "@types/dockerode": "^2.5.32",
     "@types/express": "^4.17.6",
     "@types/express-serve-static-core": "^4.17.5",
simple-backstage-app$ 

yarn install and then yarn tsc throws quite a number of errors, most of which can be resolved by seeing the individual package or plugin READMEs to see what's changed....

simple-backstage-app$ yarn tsc
yarn run v1.22.10
$ tsc
packages/app/src/apis.ts:34:10 - error TS2305: Module '"../../../node_modules/@backstage/plugin-tech-radar/dist"' has no exported member 'techRadarApiRef'.

34 import { techRadarApiRef, TechRadar } from '@backstage/plugin-tech-radar';
            ~~~~~~~~~~~~~~~

packages/app/src/apis.ts:34:27 - error TS2305: Module '"../../../node_modules/@backstage/plugin-tech-radar/dist"' has no exported member 'TechRadar'.

34 import { techRadarApiRef, TechRadar } from '@backstage/plugin-tech-radar';
                             ~~~~~~~~~

packages/app/src/apis.ts:84:21 - error TS2345: Argument of type 'string' is not assignable to parameter of type 'Options'.

84     new CircleCIApi(`${backendUrl}/proxy/circleci/api`),
                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

packages/app/src/App.tsx:15:3 - error TS2741: Property '[Symbol.iterator]' is missing in type '(config: ConfigApi) => ApiRegistry' but required in type 'Iterable<ApiFactory<unknown, unknown, { [x: string]: unknown; }>>'.

15   apis,
     ~~~~

  node_modules/typescript/lib/lib.es2015.iterable.d.ts:51:5
    51     [Symbol.iterator](): Iterator<T>;
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    '[Symbol.iterator]' is declared here.

packages/app/src/App.tsx:48:10 - error TS2604: JSX element type 'AppRoutes' does not have any construct or call signatures.

48         <AppRoutes />
            ~~~~~~~~~

packages/app/src/sidebar.tsx:15:3 - error TS2305: Module '"../../../node_modules/@backstage/core/dist"' has no exported member 'SidebarUserSettings'.

15   SidebarUserSettings,
     ~~~~~~~~~~~~~~~~~~~

packages/app/src/sidebar.tsx:16:3 - error TS2305: Module '"../../../node_modules/@backstage/core/dist"' has no exported member 'SidebarThemeToggle'.

16   SidebarThemeToggle,
     ~~~~~~~~~~~~~~~~~~

packages/app/src/sidebar.tsx:17:3 - error TS2305: Module '"../../../node_modules/@backstage/core/dist"' has no exported member 'SidebarPinButton'.

17   SidebarPinButton,
     ~~~~~~~~~~~~~~~~

packages/app/src/sidebar.tsx:18:3 - error TS2305: Module '"../../../node_modules/@backstage/core/dist"' has no exported member 'DefaultProviderSettings'.

18   DefaultProviderSettings,
     ~~~~~~~~~~~~~~~~~~~~~~~

packages/backend/src/index.ts:38:22 - error TS2322: Type 'import("/Users/alan/src/simple-backstage-app/node_modules/knex/types/index")<any, unknown[]>' is not assignable to type 'import("/Users/alan/src/simple-backstage-app/packages/backend/node_modules/knex/types/index")<any, unknown[]>'.
  Types of property 'raw' are incompatible.
    Type 'import("/Users/alan/src/simple-backstage-app/node_modules/knex/types/index").RawBuilder<any, any>' is not assignable to type 'import("/Users/alan/src/simple-backstage-app/packages/backend/node_modules/knex/types/index").RawBuilder<any, any>'.
      Types of parameters 'value' and 'value' are incompatible.
        Type 'import("/Users/alan/src/simple-backstage-app/packages/backend/node_modules/knex/types/index").Value' is not assignable to type 'import("/Users/alan/src/simple-backstage-app/node_modules/knex/types/index").Value'.
          Type 'Raw<any>' is not assignable to type 'Value'.
            Type 'import("/Users/alan/src/simple-backstage-app/packages/backend/node_modules/knex/types/index").Raw<any>' is not assignable to type 'import("/Users/alan/src/simple-backstage-app/node_modules/knex/types/index").Raw<any>'.
              The types of 'toSQL().bindings' are incompatible between these types.
                Type 'readonly import("/Users/alan/src/simple-backstage-app/packages/backend/node_modules/knex/types/index").Value[]' is not assignable to type 'readonly import("/Users/alan/src/simple-backstage-app/node_modules/knex/types/index").Value[]'.
                  Type 'import("/Users/alan/src/simple-backstage-app/packages/backend/node_modules/knex/types/index").Value' is not assignable to type 'import("/Users/alan/src/simple-backstage-app/node_modules/knex/types/index").Value'.
                    Type 'Raw<any>' is not assignable to type 'Value'.

38     return { logger, database, config };
                        ~~~~~~~~

  packages/backend/src/types.ts:7:3
    7   database: Knex;
        ~~~~~~~~
    The expected type comes from property 'database' which is declared here on type 'PluginEnvironment'

packages/backend/src/index.ts:43:25 - error TS2554: Expected 1 arguments, but got 0.

43   const configs = await loadBackendConfig();
                           ~~~~~~~~~~~~~~~~~~~

  node_modules/@backstage/backend-common/dist/index.d.ts:19:36
    19 declare function loadBackendConfig(options: Options): Promise<Config>;
                                          ~~~~~~~~~~~~~~~~
    An argument for 'options' was not provided.

packages/backend/src/index.ts:44:49 - error TS2345: Argument of type 'Config' is not assignable to parameter of type 'AppConfig[]'.
  Type 'Config' is missing the following properties from type 'AppConfig[]': length, pop, push, concat, and 27 more.

44   const configReader = ConfigReader.fromConfigs(configs);
                                                   ~~~~~~~

packages/backend/src/index.ts:45:35 - error TS2345: Argument of type 'Config' is not assignable to parameter of type 'AppConfig[]'.

45   const createEnv = makeCreateEnv(configs);
                                     ~~~~~~~

packages/backend/src/plugins/auth.ts:9:47 - error TS2741: Property 'getClient' is missing in type 'Knex<any, unknown[]>' but required in type 'PluginDatabaseManager'.

9   return await createRouter({ logger, config, database });
                                                ~~~~~~~~

  node_modules/@backstage/backend-common/dist/index.d.ts:48:5
    48     getClient(): Promise<knex>;
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    'getClient' is declared here.
  node_modules/@backstage/plugin-auth-backend/dist/index.d.ts:179:5
    179     database: PluginDatabaseManager;
            ~~~~~~~~
    The expected type comes from property 'database' which is declared here on type 'RouterOptions'

packages/backend/src/plugins/catalog.ts:18:46 - error TS2345: Argument of type '{ logger: winston.Logger; config: Config; }' is not assignable to parameter of type 'Options'.
  Type '{ logger: Logger; config: Config; }' is missing the following properties from type 'Options': reader, processors, rulesEnforcer, policy

18   const locationReader = new LocationReaders({ logger, config });
                                                ~~~~~~~~~~~~~~~~~~

packages/backend/src/plugins/catalog.ts:20:51 - error TS2345: Argument of type 'import("/Users/alan/src/simple-backstage-app/packages/backend/node_modules/knex/types/index")<any, unknown[]>' is not assignable to parameter of type 'import("/Users/alan/src/simple-backstage-app/node_modules/knex/types/index")<any, unknown[]>'.
  Type 'Knex<any, unknown[]>' is missing the following properties from type 'Knex<any, unknown[]>': userParams, withUserParams, clear, onConflict

20   const db = await DatabaseManager.createDatabase(database, { logger });
                                                     ~~~~~~~~

packages/backend/src/plugins/catalog.ts:21:27 - error TS2554: Expected 2 arguments, but got 1.

21   const entitiesCatalog = new DatabaseEntitiesCatalog(db);
                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  node_modules/@backstage/plugin-catalog-backend/dist/index.d.ts:242:37
    242     constructor(database: Database, logger: Logger);
                                            ~~~~~~~~~~~~~~
    An argument for 'logger' was not provided.

packages/backend/src/plugins/proxy.ts:9:47 - error TS2345: Argument of type '{ logger: winston.Logger; config: Config; pathPrefix: string; }' is not assignable to parameter of type 'RouterOptions'.
  Object literal may only specify known properties, and 'pathPrefix' does not exist in type 'RouterOptions'.

9   return await createRouter({ logger, config, pathPrefix });
                                                ~~~~~~~~~~

packages/backend/src/plugins/scaffolder.ts:30:41 - error TS2345: Argument of type '{ client: { [x: string]: any; } & { [x: string]: any; } & Octokit & void & { paginate: PaginateInterface; } & RestEndpointMethods; }' is not assignable to parameter of type 'GithubPublisherParams'.
  Type '{ client: { [x: string]: any; } & { [x: string]: any; } & Octokit & void & { paginate: PaginateInterface; } & RestEndpointMethods; }' is missing the following properties from type 'GithubPublisherParams': token, repoVisibility

30   const publisher = new GithubPublisher({ client: githubClient });
                                           ~~~~~~~~~~~~~~~~~~~~~~~~

packages/backend/src/plugins/scaffolder.ts:38:5 - error TS2322: Type 'import("/Users/alan/src/simple-backstage-app/packages/backend/node_modules/@types/dockerode/index")' is not assignable to type 'import("/Users/alan/src/simple-backstage-app/node_modules/@types/dockerode/index")'.
  The types returned by 'getService(...)' are incompatible between these types.
    Property 'ID' is missing in type 'import("/Users/alan/src/simple-backstage-app/packages/backend/node_modules/@types/dockerode/index").Service' but required in type 'import("/Users/alan/src/simple-backstage-app/node_modules/@types/dockerode/index").Service'.

38     dockerClient,
       ~~~~~~~~~~~~

  node_modules/@types/dockerode/index.d.ts:1317:9
    1317         ID: string;
                 ~~
    'ID' is declared here.
  node_modules/@backstage/plugin-scaffolder-backend/dist/index.d.ts:323:5
    323     dockerClient: Docker;
            ~~~~~~~~~~~~
    The expected type comes from property 'dockerClient' which is declared here on type 'RouterOptions'

packages/backend/src/plugins/techdocs.ts:4:3 - error TS2305: Module '"../../../../node_modules/@backstage/plugin-techdocs-backend/dist"' has no exported member 'GithubPreparer'.

4   GithubPreparer,
    ~~~~~~~~~~~~~~

packages/backend/src/plugins/techdocs.ts:7:3 - error TS2305: Module '"../../../../node_modules/@backstage/plugin-techdocs-backend/dist"' has no exported member 'LocalPublish'.

7   LocalPublish,
    ~~~~~~~~~~~~

packages/backend/src/plugins/techdocs.ts:18:29 - error TS2554: Expected 2 arguments, but got 1.

18   const techdocsGenerator = new TechdocsGenerator(logger);
                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  node_modules/@backstage/techdocs-common/dist/index.d.ts:76:33
    76     constructor(logger: Logger, config: Config);
                                       ~~~~~~~~~~~~~~
    An argument for 'config' was not provided.

packages/backend/src/plugins/techdocs.ts:37:5 - error TS2322: Type 'import("/Users/alan/src/simple-backstage-app/packages/backend/node_modules/@types/dockerode/index")' is not assignable to type 'import("/Users/alan/src/simple-backstage-app/node_modules/@types/dockerode/index")'.

37     dockerClient,
       ~~~~~~~~~~~~

  node_modules/@backstage/plugin-techdocs-backend/dist/index.d.ts:18:5
    18     dockerClient: Docker;
           ~~~~~~~~~~~~
    The expected type comes from property 'dockerClient' which is declared here on type 'RouterOptions'

Found 24 errors.

error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
simple-backstage-app$ 
shabbskagalwala commented 3 years ago

Bumping this issue, running into a similar problem. Any solution to fix this?

gruberdev commented 2 years ago

Just happened to face this issue as well. Perhaps upgrading the existing yarn.lock would produce better results?