@backstage/create-app 0.4.13 → 0.4.18-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +449 -0
- package/dist/index.cjs.js +66 -64
- package/dist/index.cjs.js.map +1 -1
- package/package.json +2 -2
- package/templates/default-app/app-config.yaml.hbs +5 -1
- package/templates/default-app/packages/app/package.json.hbs +3 -2
- package/templates/default-app/packages/app/src/App.tsx +7 -1
- package/templates/default-app/packages/app/src/components/catalog/EntityPage.tsx +44 -2
- package/templates/default-app/packages/app/src/components/search/SearchPage.tsx +31 -0
- package/templates/default-app/packages/backend/package.json.hbs +1 -1
- package/templates/default-app/packages/backend/src/plugins/auth.ts +8 -1
- package/templates/default-app/packages/backend/src/plugins/search.ts +4 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,454 @@
|
|
|
1
1
|
# @backstage/create-app
|
|
2
2
|
|
|
3
|
+
## 0.4.18-next.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- f27f5197e2: Apply the fix from `0.4.16`, which is part of the `v0.65.1` release of Backstage.
|
|
8
|
+
- 2687029a67: Update backend-to-backend auth link in configuration file comment
|
|
9
|
+
- 24ef62048c: Adds missing `/catalog-graph` route to `<CatalogGraphPage/>`.
|
|
10
|
+
|
|
11
|
+
To fix this problem for a recently created app please update your `app/src/App.tsx`
|
|
12
|
+
|
|
13
|
+
```diff
|
|
14
|
+
+ import { CatalogGraphPage } from '@backstage/plugin-catalog-graph';
|
|
15
|
+
|
|
16
|
+
... omitted ...
|
|
17
|
+
|
|
18
|
+
</Route>
|
|
19
|
+
<Route path="/settings" element={<UserSettingsPage />} />
|
|
20
|
+
+ <Route path="/catalog-graph" element={<CatalogGraphPage />} />
|
|
21
|
+
</FlatRoutes>
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
- cef64b1561: Added `tokenManager` as a required property for the auth-backend `createRouter` function. This dependency is used to issue server tokens that are used by the `CatalogIdentityClient` when looking up users and their group membership during authentication.
|
|
25
|
+
|
|
26
|
+
These changes are **required** to `packages/backend/src/plugins/auth.ts`:
|
|
27
|
+
|
|
28
|
+
```diff
|
|
29
|
+
export default async function createPlugin({
|
|
30
|
+
logger,
|
|
31
|
+
database,
|
|
32
|
+
config,
|
|
33
|
+
discovery,
|
|
34
|
+
+ tokenManager,
|
|
35
|
+
}: PluginEnvironment): Promise<Router> {
|
|
36
|
+
return await createRouter({
|
|
37
|
+
logger,
|
|
38
|
+
config,
|
|
39
|
+
database,
|
|
40
|
+
discovery,
|
|
41
|
+
+ tokenManager,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
- e39d88bd84: Switched the `app` dependency in the backend to use a file target rather than version.
|
|
47
|
+
|
|
48
|
+
To apply this change to an existing app, make the following change to `packages/backend/package.json`:
|
|
49
|
+
|
|
50
|
+
```diff
|
|
51
|
+
"dependencies": {
|
|
52
|
+
- "app": "0.0.0",
|
|
53
|
+
+ "app": "file:../app",
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## 0.4.16
|
|
57
|
+
|
|
58
|
+
### Patch Changes
|
|
59
|
+
|
|
60
|
+
- c945cd9f7e: Adds missing `/catalog-graph` route to `<CatalogGraphPage/>`.
|
|
61
|
+
|
|
62
|
+
To fix this problem for a recently created app please update your `app/src/App.tsx`
|
|
63
|
+
|
|
64
|
+
```diff
|
|
65
|
+
+ import { CatalogGraphPage } from '@backstage/plugin-catalog-graph';
|
|
66
|
+
|
|
67
|
+
... omitted ...
|
|
68
|
+
|
|
69
|
+
</Route>
|
|
70
|
+
<Route path="/settings" element={<UserSettingsPage />} />
|
|
71
|
+
+ <Route path="/catalog-graph" element={<CatalogGraphPage />} />
|
|
72
|
+
</FlatRoutes>
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## 0.4.15
|
|
76
|
+
|
|
77
|
+
### Patch Changes
|
|
78
|
+
|
|
79
|
+
- 01b27d547c: Added three additional required properties to the search-backend `createRouter` function to support filtering search results based on permissions. To make this change to an existing app, add the required parameters to the `createRouter` call in `packages/backend/src/plugins/search.ts`:
|
|
80
|
+
|
|
81
|
+
```diff
|
|
82
|
+
export default async function createPlugin({
|
|
83
|
+
logger,
|
|
84
|
+
+ permissions,
|
|
85
|
+
discovery,
|
|
86
|
+
config,
|
|
87
|
+
tokenManager,
|
|
88
|
+
}: PluginEnvironment) {
|
|
89
|
+
/* ... */
|
|
90
|
+
|
|
91
|
+
return await createRouter({
|
|
92
|
+
engine: indexBuilder.getSearchEngine(),
|
|
93
|
+
+ types: indexBuilder.getDocumentTypes(),
|
|
94
|
+
+ permissions,
|
|
95
|
+
+ config,
|
|
96
|
+
logger,
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
- a0d446c8ec: Replaced EntitySystemDiagramCard with EntityCatalogGraphCard
|
|
102
|
+
|
|
103
|
+
To make this change to an existing app:
|
|
104
|
+
|
|
105
|
+
Add `@backstage/catalog-graph-plugin` as a `dependency` in `packages/app/package.json`
|
|
106
|
+
|
|
107
|
+
Apply the following changes to the `packages/app/src/components/catalog/EntityPage.tsx` file:
|
|
108
|
+
|
|
109
|
+
```diff
|
|
110
|
+
+ import {
|
|
111
|
+
+ Direction,
|
|
112
|
+
+ EntityCatalogGraphCard,
|
|
113
|
+
+ } from '@backstage/plugin-catalog-graph';
|
|
114
|
+
+ import {
|
|
115
|
+
+ RELATION_API_CONSUMED_BY,
|
|
116
|
+
+ RELATION_API_PROVIDED_BY,
|
|
117
|
+
+ RELATION_CONSUMES_API,
|
|
118
|
+
+ RELATION_DEPENDENCY_OF,
|
|
119
|
+
+ RELATION_DEPENDS_ON,
|
|
120
|
+
+ RELATION_HAS_PART,
|
|
121
|
+
+ RELATION_PART_OF,
|
|
122
|
+
+ RELATION_PROVIDES_API,
|
|
123
|
+
+ } from '@backstage/catalog-model';
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
```diff
|
|
127
|
+
<EntityLayout.Route path="/diagram" title="Diagram">
|
|
128
|
+
- <EntitySystemDiagramCard />
|
|
129
|
+
+ <EntityCatalogGraphCard
|
|
130
|
+
+ variant="gridItem"
|
|
131
|
+
+ direction={Direction.TOP_BOTTOM}
|
|
132
|
+
+ title="System Diagram"
|
|
133
|
+
+ height={700}
|
|
134
|
+
+ relations={[
|
|
135
|
+
+ RELATION_PART_OF,
|
|
136
|
+
+ RELATION_HAS_PART,
|
|
137
|
+
+ RELATION_API_CONSUMED_BY,
|
|
138
|
+
+ RELATION_API_PROVIDED_BY,
|
|
139
|
+
+ RELATION_CONSUMES_API,
|
|
140
|
+
+ RELATION_PROVIDES_API,
|
|
141
|
+
+ RELATION_DEPENDENCY_OF,
|
|
142
|
+
+ RELATION_DEPENDS_ON,
|
|
143
|
+
+ ]}
|
|
144
|
+
+ unidirectional={false}
|
|
145
|
+
+ />
|
|
146
|
+
</EntityLayout.Route>
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
```diff
|
|
150
|
+
const cicdContent = (
|
|
151
|
+
<Grid item md={6}>
|
|
152
|
+
<EntityAboutCard variant="gridItem" />
|
|
153
|
+
</Grid>
|
|
154
|
+
+ <Grid item md={6} xs={12}>
|
|
155
|
+
+ <EntityCatalogGraphCard variant="gridItem" height={400} />
|
|
156
|
+
+ </Grid>
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
Add the above component in `overviewContent`, `apiPage` , `systemPage` and domainPage` as well.
|
|
160
|
+
|
|
161
|
+
- 4aca2a5307: An example instance of a `<SearchFilter.Select />` with asynchronously loaded values was added to the composed `SearchPage.tsx`, allowing searches bound to the `techdocs` type to be filtered by entity name.
|
|
162
|
+
|
|
163
|
+
This is an entirely optional change; if you wish to adopt it, you can make the following (or similar) changes to your search page layout:
|
|
164
|
+
|
|
165
|
+
```diff
|
|
166
|
+
--- a/packages/app/src/components/search/SearchPage.tsx
|
|
167
|
+
+++ b/packages/app/src/components/search/SearchPage.tsx
|
|
168
|
+
@@ -2,6 +2,10 @@ import React from 'react';
|
|
169
|
+
import { makeStyles, Theme, Grid, List, Paper } from '@material-ui/core';
|
|
170
|
+
|
|
171
|
+
import { CatalogResultListItem } from '@backstage/plugin-catalog';
|
|
172
|
+
+import {
|
|
173
|
+
+ catalogApiRef,
|
|
174
|
+
+ CATALOG_FILTER_EXISTS,
|
|
175
|
+
+} from '@backstage/plugin-catalog-react';
|
|
176
|
+
import { DocsResultListItem } from '@backstage/plugin-techdocs';
|
|
177
|
+
|
|
178
|
+
import {
|
|
179
|
+
@@ -10,6 +14,7 @@ import {
|
|
180
|
+
SearchResult,
|
|
181
|
+
SearchType,
|
|
182
|
+
DefaultResultListItem,
|
|
183
|
+
+ useSearch,
|
|
184
|
+
} from '@backstage/plugin-search';
|
|
185
|
+
import {
|
|
186
|
+
CatalogIcon,
|
|
187
|
+
@@ -18,6 +23,7 @@ import {
|
|
188
|
+
Header,
|
|
189
|
+
Page,
|
|
190
|
+
} from '@backstage/core-components';
|
|
191
|
+
+import { useApi } from '@backstage/core-plugin-api';
|
|
192
|
+
|
|
193
|
+
const useStyles = makeStyles((theme: Theme) => ({
|
|
194
|
+
bar: {
|
|
195
|
+
@@ -36,6 +42,8 @@ const useStyles = makeStyles((theme: Theme) => ({
|
|
196
|
+
|
|
197
|
+
const SearchPage = () => {
|
|
198
|
+
const classes = useStyles();
|
|
199
|
+
+ const { types } = useSearch();
|
|
200
|
+
+ const catalogApi = useApi(catalogApiRef);
|
|
201
|
+
|
|
202
|
+
return (
|
|
203
|
+
<Page themeId="home">
|
|
204
|
+
@@ -65,6 +73,27 @@ const SearchPage = () => {
|
|
205
|
+
]}
|
|
206
|
+
/>
|
|
207
|
+
<Paper className={classes.filters}>
|
|
208
|
+
+ {types.includes('techdocs') && (
|
|
209
|
+
+ <SearchFilter.Select
|
|
210
|
+
+ className={classes.filter}
|
|
211
|
+
+ label="Entity"
|
|
212
|
+
+ name="name"
|
|
213
|
+
+ values={async () => {
|
|
214
|
+
+ // Return a list of entities which are documented.
|
|
215
|
+
+ const { items } = await catalogApi.getEntities({
|
|
216
|
+
+ fields: ['metadata.name'],
|
|
217
|
+
+ filter: {
|
|
218
|
+
+ 'metadata.annotations.backstage.io/techdocs-ref':
|
|
219
|
+
+ CATALOG_FILTER_EXISTS,
|
|
220
|
+
+ },
|
|
221
|
+
+ });
|
|
222
|
+
+
|
|
223
|
+
+ const names = items.map(entity => entity.metadata.name);
|
|
224
|
+
+ names.sort();
|
|
225
|
+
+ return names;
|
|
226
|
+
+ }}
|
|
227
|
+
+ />
|
|
228
|
+
+ )}
|
|
229
|
+
<SearchFilter.Select
|
|
230
|
+
className={classes.filter}
|
|
231
|
+
name="kind"
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
- 1dbe63ec39: A `label` prop was added to `<SearchFilter.* />` components in order to allow
|
|
235
|
+
user-friendly label strings (as well as the option to omit a label). In order
|
|
236
|
+
to maintain labels on your existing filters, add a `label` prop to them in your
|
|
237
|
+
`SearchPage.tsx`.
|
|
238
|
+
|
|
239
|
+
```diff
|
|
240
|
+
--- a/packages/app/src/components/search/SearchPage.tsx
|
|
241
|
+
+++ b/packages/app/src/components/search/SearchPage.tsx
|
|
242
|
+
@@ -96,11 +96,13 @@ const SearchPage = () => {
|
|
243
|
+
)}
|
|
244
|
+
<SearchFilter.Select
|
|
245
|
+
className={classes.filter}
|
|
246
|
+
+ label="Kind"
|
|
247
|
+
name="kind"
|
|
248
|
+
values={['Component', 'Template']}
|
|
249
|
+
/>
|
|
250
|
+
<SearchFilter.Checkbox
|
|
251
|
+
className={classes.filter}
|
|
252
|
+
+ label="Lifecycle"
|
|
253
|
+
name="lifecycle"
|
|
254
|
+
values={['experimental', 'production']}
|
|
255
|
+
/>
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
## 0.4.14
|
|
259
|
+
|
|
260
|
+
### Patch Changes
|
|
261
|
+
|
|
262
|
+
- d4941024bc: Rebind external route for catalog import plugin from `scaffolderPlugin.routes.root` to `catalogImportPlugin.routes.importPage`.
|
|
263
|
+
|
|
264
|
+
To make this change to an existing app, make the following change to `packages/app/src/App.tsx`
|
|
265
|
+
|
|
266
|
+
```diff
|
|
267
|
+
const App = createApp({
|
|
268
|
+
...
|
|
269
|
+
bindRoutes({ bind }) {
|
|
270
|
+
...
|
|
271
|
+
bind(apiDocsPlugin.externalRoutes, {
|
|
272
|
+
- createComponent: scaffolderPlugin.routes.root,
|
|
273
|
+
+ registerApi: catalogImportPlugin.routes.importPage,
|
|
274
|
+
});
|
|
275
|
+
...
|
|
276
|
+
},
|
|
277
|
+
});
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
- b5402d6d72: Migrated the app template to React 17.
|
|
281
|
+
|
|
282
|
+
To apply this change to an existing app, make sure you have updated to the latest version of `@backstage/cli`, and make the following change to `packages/app/package.json`:
|
|
283
|
+
|
|
284
|
+
```diff
|
|
285
|
+
"history": "^5.0.0",
|
|
286
|
+
- "react": "^16.13.1",
|
|
287
|
+
- "react-dom": "^16.13.1",
|
|
288
|
+
+ "react": "^17.0.2",
|
|
289
|
+
+ "react-dom": "^17.0.2",
|
|
290
|
+
"react-router": "6.0.0-beta.0",
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
Since we have recently moved over all `react` and `react-dom` dependencies to `peerDependencies` of all packages, and included React 17 in the version range, this should be all you need to do. If you end up with duplicate React installations, first make sure that all of your plugins are up-to-date, including ones for example from `@roadiehq`. If that doesn't work, you may need to fall back to adding [Yarn resolutions](https://classic.yarnpkg.com/lang/en/docs/selective-version-resolutions/) in the `package.json` of your project root:
|
|
294
|
+
|
|
295
|
+
```diff
|
|
296
|
+
+ "resolutions": {
|
|
297
|
+
+ "react": "^17.0.2",
|
|
298
|
+
+ "react-dom": "^17.0.2"
|
|
299
|
+
+ },
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
- 5e8d278f8e: Added an external route binding from the `org` plugin to the catalog index page.
|
|
303
|
+
|
|
304
|
+
This change is needed because `@backstage/plugin-org` now has a required external route that needs to be bound for the app to start.
|
|
305
|
+
|
|
306
|
+
To apply this change to an existing app, make the following change to `packages/app/src/App.tsx`:
|
|
307
|
+
|
|
308
|
+
```diff
|
|
309
|
+
import { ScaffolderPage, scaffolderPlugin } from '@backstage/plugin-scaffolder';
|
|
310
|
+
+import { orgPlugin } from '@backstage/plugin-org';
|
|
311
|
+
import { SearchPage } from '@backstage/plugin-search';
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
And further down within the `createApp` call:
|
|
315
|
+
|
|
316
|
+
```diff
|
|
317
|
+
bind(scaffolderPlugin.externalRoutes, {
|
|
318
|
+
registerComponent: catalogImportPlugin.routes.importPage,
|
|
319
|
+
});
|
|
320
|
+
+ bind(orgPlugin.externalRoutes, {
|
|
321
|
+
+ catalogIndex: catalogPlugin.routes.catalogIndex,
|
|
322
|
+
+ });
|
|
323
|
+
},
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
- fb08e2f285: Updated the configuration of the `app-backend` plugin to enable the static asset store by passing on `database` from the plugin environment to `createRouter`.
|
|
327
|
+
|
|
328
|
+
To apply this change to an existing app, make the following change to `packages/backend/src/plugins/app.ts`:
|
|
329
|
+
|
|
330
|
+
```diff
|
|
331
|
+
export default async function createPlugin({
|
|
332
|
+
logger,
|
|
333
|
+
config,
|
|
334
|
+
+ database,
|
|
335
|
+
}: PluginEnvironment): Promise<Router> {
|
|
336
|
+
return await createRouter({
|
|
337
|
+
logger,
|
|
338
|
+
config,
|
|
339
|
+
+ database,
|
|
340
|
+
appPackageName: 'app',
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
- 7ba416be78: You can now add `SidebarGroup`s to the current `Sidebar`. This will not affect how the current sidebar is displayed, but allows a customization on how the `MobileSidebar` on smaller screens will look like. A `SidebarGroup` will be displayed with the given icon in the `MobileSidebar`.
|
|
346
|
+
|
|
347
|
+
A `SidebarGroup` can either link to an existing page (e.g. `/search` or `/settings`) or wrap components, which will be displayed in a full-screen overlay menu (e.g. `Menu`).
|
|
348
|
+
|
|
349
|
+
```diff
|
|
350
|
+
<Sidebar>
|
|
351
|
+
<SidebarLogo />
|
|
352
|
+
+ <SidebarGroup label="Search" icon={<SearchIcon />} to="/search">
|
|
353
|
+
<SidebarSearchModal />
|
|
354
|
+
+ </SidebarGroup>
|
|
355
|
+
<SidebarDivider />
|
|
356
|
+
+ <SidebarGroup label="Menu" icon={<MenuIcon />}>
|
|
357
|
+
<SidebarItem icon={HomeIcon} to="catalog" text="Home" />
|
|
358
|
+
<SidebarItem icon={CreateComponentIcon} to="create" text="Create..." />
|
|
359
|
+
<SidebarDivider />
|
|
360
|
+
<SidebarScrollWrapper>
|
|
361
|
+
<SidebarItem icon={MapIcon} to="tech-radar" text="Tech Radar" />
|
|
362
|
+
</SidebarScrollWrapper>
|
|
363
|
+
+ </SidebarGroup>
|
|
364
|
+
<SidebarSpace />
|
|
365
|
+
<SidebarDivider />
|
|
366
|
+
+ <SidebarGroup
|
|
367
|
+
+ label="Settings"
|
|
368
|
+
+ icon={<UserSettingsSignInAvatar />}
|
|
369
|
+
+ to="/settings"
|
|
370
|
+
+ >
|
|
371
|
+
<SidebarSettings />
|
|
372
|
+
+ </SidebarGroup>
|
|
373
|
+
</Sidebar>
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
Additionally, you can order the groups differently in the `MobileSidebar` than in the usual `Sidebar` simply by giving a group a priority. The groups will be displayed in descending order from left to right.
|
|
377
|
+
|
|
378
|
+
```diff
|
|
379
|
+
<SidebarGroup
|
|
380
|
+
label="Settings"
|
|
381
|
+
icon={<UserSettingsSignInAvatar />}
|
|
382
|
+
to="/settings"
|
|
383
|
+
+ priority={1}
|
|
384
|
+
>
|
|
385
|
+
<SidebarSettings />
|
|
386
|
+
</SidebarGroup>
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
If you decide against adding `SidebarGroup`s to your `Sidebar` the `MobileSidebar` will contain one default menu item, which will open a full-screen overlay menu displaying all the content of the current `Sidebar`.
|
|
390
|
+
|
|
391
|
+
More information on the `SidebarGroup` & the `MobileSidebar` component can be found in the changeset for the `core-components`.
|
|
392
|
+
|
|
393
|
+
- 08fa6a604a: The app template has been updated to add an explicit dependency on `typescript` in the root `package.json`. This is because it was removed as a dependency of `@backstage/cli` in order to decouple the TypeScript versioning in Backstage projects.
|
|
394
|
+
|
|
395
|
+
To apply this change in an existing app, add a `typescript` dependency to your `package.json` in the project root:
|
|
396
|
+
|
|
397
|
+
```json
|
|
398
|
+
"dependencies": {
|
|
399
|
+
...
|
|
400
|
+
"typescript": "~4.5.4",
|
|
401
|
+
}
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
We recommend using a `~` version range since TypeScript releases do not adhere to semver.
|
|
405
|
+
|
|
406
|
+
It may be the case that you end up with errors if you upgrade the TypeScript version. This is because there was a change to TypeScript not long ago that defaulted the type of errors caught in `catch` blocks to `unknown`. You can work around this by adding `"useUnknownInCatchVariables": false` to the `"compilerOptions"` in your `tsconfig.json`:
|
|
407
|
+
|
|
408
|
+
```json
|
|
409
|
+
"compilerOptions": {
|
|
410
|
+
...
|
|
411
|
+
"useUnknownInCatchVariables": false
|
|
412
|
+
}
|
|
413
|
+
```
|
|
414
|
+
|
|
415
|
+
Another option is to use the utilities from `@backstage/errors` to assert the type of errors caught in `catch` blocks:
|
|
416
|
+
|
|
417
|
+
```ts
|
|
418
|
+
import { assertError, isError } from '@backstage/errors';
|
|
419
|
+
|
|
420
|
+
try {
|
|
421
|
+
...
|
|
422
|
+
} catch (error) {
|
|
423
|
+
assertError(error);
|
|
424
|
+
...
|
|
425
|
+
// OR
|
|
426
|
+
if (isError(error)) {
|
|
427
|
+
...
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
```
|
|
431
|
+
|
|
432
|
+
Yet another issue you might run into when upgrading TypeScript is incompatibilities in the types from `react-use`. The error you would run into looks something like this:
|
|
433
|
+
|
|
434
|
+
```plain
|
|
435
|
+
node_modules/react-use/lib/usePermission.d.ts:1:54 - error TS2304: Cannot find name 'DevicePermissionDescriptor'.
|
|
436
|
+
|
|
437
|
+
1 declare type PermissionDesc = PermissionDescriptor | DevicePermissionDescriptor | MidiPermissionDescriptor | PushPermissionDescriptor;
|
|
438
|
+
```
|
|
439
|
+
|
|
440
|
+
If you encounter this error, the simplest fix is to replace full imports of `react-use` with more specific ones. For example, the following:
|
|
441
|
+
|
|
442
|
+
```ts
|
|
443
|
+
import { useAsync } from 'react-use';
|
|
444
|
+
```
|
|
445
|
+
|
|
446
|
+
Would be converted into this:
|
|
447
|
+
|
|
448
|
+
```ts
|
|
449
|
+
import useAsync from 'react-use/lib/useAsync';
|
|
450
|
+
```
|
|
451
|
+
|
|
3
452
|
## 0.4.13
|
|
4
453
|
|
|
5
454
|
### Patch Changes
|
package/dist/index.cjs.js
CHANGED
|
@@ -55,105 +55,108 @@ ${chalk__default["default"].red(`${error}`)}
|
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
var version$
|
|
58
|
+
var version$E = "0.4.18-next.0";
|
|
59
59
|
|
|
60
|
-
var version$
|
|
60
|
+
var version$D = "0.1.6-next.0";
|
|
61
61
|
|
|
62
|
-
var version$
|
|
62
|
+
var version$C = "0.10.5";
|
|
63
63
|
|
|
64
|
-
var version$
|
|
64
|
+
var version$B = "0.1.4";
|
|
65
65
|
|
|
66
|
-
var version$
|
|
66
|
+
var version$A = "0.5.5";
|
|
67
67
|
|
|
68
|
-
var version$
|
|
68
|
+
var version$z = "0.9.10";
|
|
69
69
|
|
|
70
|
-
var version$
|
|
70
|
+
var version$y = "0.13.1-next.0";
|
|
71
71
|
|
|
72
|
-
var version$
|
|
72
|
+
var version$x = "0.1.13";
|
|
73
73
|
|
|
74
|
-
var version$
|
|
74
|
+
var version$w = "0.5.1";
|
|
75
75
|
|
|
76
|
-
var version$
|
|
76
|
+
var version$v = "0.8.7-next.0";
|
|
77
77
|
|
|
78
|
-
var version$
|
|
78
|
+
var version$u = "0.6.0";
|
|
79
79
|
|
|
80
|
-
var version$
|
|
80
|
+
var version$t = "0.2.0";
|
|
81
81
|
|
|
82
|
-
var version$
|
|
82
|
+
var version$s = "0.1.20-next.0";
|
|
83
83
|
|
|
84
|
-
var version$
|
|
84
|
+
var version$r = "0.2.3";
|
|
85
85
|
|
|
86
|
-
var version$
|
|
86
|
+
var version$q = "0.2.14";
|
|
87
87
|
|
|
88
|
-
var version$
|
|
88
|
+
var version$p = "0.7.1-next.0";
|
|
89
89
|
|
|
90
|
-
var version$
|
|
90
|
+
var version$o = "0.3.22";
|
|
91
91
|
|
|
92
|
-
var version$
|
|
92
|
+
var version$n = "0.9.0-next.0";
|
|
93
93
|
|
|
94
|
-
var version$
|
|
94
|
+
var version$m = "0.7.11-next.0";
|
|
95
95
|
|
|
96
|
-
var version$
|
|
96
|
+
var version$l = "0.6.13-next.0";
|
|
97
97
|
|
|
98
|
-
var version$
|
|
98
|
+
var version$k = "0.21.2-next.0";
|
|
99
99
|
|
|
100
|
-
var version$
|
|
100
|
+
var version$j = "0.2.9-next.0";
|
|
101
101
|
|
|
102
|
-
var version$
|
|
102
|
+
var version$i = "0.8.0-next.0";
|
|
103
103
|
|
|
104
|
-
var version$
|
|
104
|
+
var version$h = "0.2.36-next.0";
|
|
105
105
|
|
|
106
|
-
var version$
|
|
106
|
+
var version$g = "0.3.28-next.0";
|
|
107
107
|
|
|
108
|
-
var version$
|
|
108
|
+
var version$f = "0.4.34-next.0";
|
|
109
109
|
|
|
110
|
-
var version$
|
|
110
|
+
var version$e = "0.2.36-next.0";
|
|
111
111
|
|
|
112
|
-
var version$
|
|
112
|
+
var version$d = "0.4.1-next.0";
|
|
113
113
|
|
|
114
|
-
var version$
|
|
114
|
+
var version$c = "0.4.0";
|
|
115
115
|
|
|
116
|
-
var version$
|
|
116
|
+
var version$b = "0.4.2-next.0";
|
|
117
117
|
|
|
118
|
-
var version$
|
|
118
|
+
var version$a = "0.2.17-next.0";
|
|
119
119
|
|
|
120
|
-
var version$
|
|
120
|
+
var version$9 = "0.1.20-next.0";
|
|
121
121
|
|
|
122
|
-
var version$
|
|
122
|
+
var version$8 = "0.12.1-next.0";
|
|
123
123
|
|
|
124
|
-
var version$
|
|
124
|
+
var version$7 = "0.15.23-next.0";
|
|
125
125
|
|
|
126
|
-
var version$
|
|
126
|
+
var version$6 = "0.6.1-next.0";
|
|
127
127
|
|
|
128
|
-
var version$
|
|
128
|
+
var version$5 = "0.4.1-next.0";
|
|
129
129
|
|
|
130
|
-
var version$
|
|
130
|
+
var version$4 = "0.4.5";
|
|
131
131
|
|
|
132
|
-
var version$
|
|
132
|
+
var version$3 = "0.5.4-next.0";
|
|
133
133
|
|
|
134
|
-
var version$
|
|
134
|
+
var version$2 = "0.13.2-next.0";
|
|
135
135
|
|
|
136
|
-
var version = "0.
|
|
136
|
+
var version$1 = "0.13.1";
|
|
137
|
+
|
|
138
|
+
var version = "0.3.18-next.0";
|
|
137
139
|
|
|
138
140
|
const packageVersions = {
|
|
139
|
-
"@backstage/app-defaults": version$
|
|
140
|
-
"@backstage/backend-common": version$
|
|
141
|
-
"@backstage/backend-tasks": version$
|
|
142
|
-
"@backstage/catalog-client": version$
|
|
143
|
-
"@backstage/catalog-model": version$
|
|
144
|
-
"@backstage/cli": version$
|
|
145
|
-
"@backstage/config": version$
|
|
146
|
-
"@backstage/core-app-api": version$
|
|
147
|
-
"@backstage/core-components": version$
|
|
148
|
-
"@backstage/core-plugin-api": version$
|
|
149
|
-
"@backstage/errors": version$
|
|
150
|
-
"@backstage/integration-react": version$
|
|
151
|
-
"@backstage/plugin-api-docs": version$
|
|
152
|
-
"@backstage/plugin-app-backend": version$
|
|
153
|
-
"@backstage/plugin-auth-backend": version$
|
|
154
|
-
"@backstage/plugin-catalog": version$
|
|
155
|
-
"@backstage/plugin-catalog-react": version$
|
|
156
|
-
"@backstage/plugin-catalog-backend": version$
|
|
141
|
+
"@backstage/app-defaults": version$D,
|
|
142
|
+
"@backstage/backend-common": version$C,
|
|
143
|
+
"@backstage/backend-tasks": version$B,
|
|
144
|
+
"@backstage/catalog-client": version$A,
|
|
145
|
+
"@backstage/catalog-model": version$z,
|
|
146
|
+
"@backstage/cli": version$y,
|
|
147
|
+
"@backstage/config": version$x,
|
|
148
|
+
"@backstage/core-app-api": version$w,
|
|
149
|
+
"@backstage/core-components": version$v,
|
|
150
|
+
"@backstage/core-plugin-api": version$u,
|
|
151
|
+
"@backstage/errors": version$t,
|
|
152
|
+
"@backstage/integration-react": version$s,
|
|
153
|
+
"@backstage/plugin-api-docs": version$p,
|
|
154
|
+
"@backstage/plugin-app-backend": version$o,
|
|
155
|
+
"@backstage/plugin-auth-backend": version$n,
|
|
156
|
+
"@backstage/plugin-catalog": version$m,
|
|
157
|
+
"@backstage/plugin-catalog-react": version$l,
|
|
158
|
+
"@backstage/plugin-catalog-backend": version$k,
|
|
159
|
+
"@backstage/plugin-catalog-graph": version$j,
|
|
157
160
|
"@backstage/plugin-catalog-import": version$i,
|
|
158
161
|
"@backstage/plugin-circleci": version$h,
|
|
159
162
|
"@backstage/plugin-explore": version$g,
|
|
@@ -173,8 +176,8 @@ const packageVersions = {
|
|
|
173
176
|
"@backstage/plugin-techdocs": version$2,
|
|
174
177
|
"@backstage/plugin-techdocs-backend": version$1,
|
|
175
178
|
"@backstage/plugin-user-settings": version,
|
|
176
|
-
"@backstage/test-utils": version$
|
|
177
|
-
"@backstage/theme": version$
|
|
179
|
+
"@backstage/test-utils": version$r,
|
|
180
|
+
"@backstage/theme": version$q
|
|
178
181
|
};
|
|
179
182
|
|
|
180
183
|
const TASK_NAME_MAX_LENGTH = 14;
|
|
@@ -309,7 +312,7 @@ async function moveAppTask(tempDir, destination, id) {
|
|
|
309
312
|
|
|
310
313
|
var createApp = async (cmd, version) => {
|
|
311
314
|
const paths = cliCommon.findPaths(__dirname);
|
|
312
|
-
const
|
|
315
|
+
const answers = await inquirer__default["default"].prompt([
|
|
313
316
|
{
|
|
314
317
|
type: "input",
|
|
315
318
|
name: "name",
|
|
@@ -329,8 +332,7 @@ var createApp = async (cmd, version) => {
|
|
|
329
332
|
message: chalk__default["default"].blue("Select database for the backend [required]"),
|
|
330
333
|
choices: ["SQLite", "PostgreSQL"]
|
|
331
334
|
}
|
|
332
|
-
];
|
|
333
|
-
const answers = await inquirer__default["default"].prompt(questions);
|
|
335
|
+
]);
|
|
334
336
|
answers.dbTypePG = answers.dbType === "PostgreSQL";
|
|
335
337
|
answers.dbTypeSqlite = answers.dbType === "SQLite";
|
|
336
338
|
const templateDir = paths.resolveOwn("templates/default-app");
|
|
@@ -376,7 +378,7 @@ var createApp = async (cmd, version) => {
|
|
|
376
378
|
};
|
|
377
379
|
|
|
378
380
|
const main = (argv) => {
|
|
379
|
-
program__default["default"].name("backstage-create-app").version(version$
|
|
381
|
+
program__default["default"].name("backstage-create-app").version(version$E).description("Creates a new app in a new directory or specified path").option("--path [directory]", "Location to store the app defaulting to a new folder with the app name").option("--skip-install", "Skip the install and builds steps after creating the app").action((cmd) => createApp(cmd, version$E));
|
|
380
382
|
program__default["default"].parse(argv);
|
|
381
383
|
};
|
|
382
384
|
process.on("unhandledRejection", (rejection) => {
|
package/dist/index.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.js","sources":["../src/lib/errors.ts","../src/lib/versions.ts","../src/lib/tasks.ts","../src/createApp.ts","../src/index.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport chalk from 'chalk';\n\nexport class CustomError extends Error {\n get name(): string {\n return this.constructor.name;\n }\n}\n\nexport class ExitCodeError extends CustomError {\n readonly code: number;\n\n constructor(code: number, command?: string) {\n if (command) {\n super(`Command '${command}' exited with code ${code}`);\n } else {\n super(`Child exited with code ${code}`);\n }\n this.code = code;\n }\n}\n\nexport function exitWithError(error: Error): never {\n if (error instanceof ExitCodeError) {\n process.stderr.write(`\\n${chalk.red(error.message)}\\n\\n`);\n process.exit(error.code);\n } else {\n process.stderr.write(`\\n${chalk.red(`${error}`)}\\n\\n`);\n process.exit(1);\n }\n}\n","/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/* eslint-disable monorepo/no-relative-import */\n\n/*\nThis is a list of all packages used by the template. If dependencies are added or removed,\nthis list should be updated as well.\n\nThe list, and the accompanying peerDependencies entries, are here to ensure correct versioning\nand bumping of this package. Without this list the version would not be bumped unless we\nmanually trigger a release.\n\nThis does not create an actual dependency on these packages and does not bring in any code.\nRelative imports are used rather than package imports to make sure the packages aren't externalized.\nRollup will extract the value of the version field in each package at build time without\nleaving any imports in place.\n*/\n\nimport { version as appDefaults } from '../../../app-defaults/package.json';\nimport { version as backendCommon } from '../../../backend-common/package.json';\nimport { version as backendTasks } from '../../../backend-tasks/package.json';\nimport { version as catalogClient } from '../../../catalog-client/package.json';\nimport { version as catalogModel } from '../../../catalog-model/package.json';\nimport { version as cli } from '../../../cli/package.json';\nimport { version as config } from '../../../config/package.json';\nimport { version as coreAppApi } from '../../../core-app-api/package.json';\nimport { version as coreComponents } from '../../../core-components/package.json';\nimport { version as corePluginApi } from '../../../core-plugin-api/package.json';\nimport { version as errors } from '../../../errors/package.json';\nimport { version as integrationReact } from '../../../integration-react/package.json';\nimport { version as testUtils } from '../../../test-utils/package.json';\nimport { version as theme } from '../../../theme/package.json';\n\nimport { version as pluginApiDocs } from '../../../../plugins/api-docs/package.json';\nimport { version as pluginAppBackend } from '../../../../plugins/app-backend/package.json';\nimport { version as pluginAuthBackend } from '../../../../plugins/auth-backend/package.json';\nimport { version as pluginCatalog } from '../../../../plugins/catalog/package.json';\nimport { version as pluginCatalogReact } from '../../../../plugins/catalog-react/package.json';\nimport { version as pluginCatalogBackend } from '../../../../plugins/catalog-backend/package.json';\nimport { version as pluginCatalogImport } from '../../../../plugins/catalog-import/package.json';\nimport { version as pluginCircleci } from '../../../../plugins/circleci/package.json';\nimport { version as pluginExplore } from '../../../../plugins/explore/package.json';\nimport { version as pluginGithubActions } from '../../../../plugins/github-actions/package.json';\nimport { version as pluginLighthouse } from '../../../../plugins/lighthouse/package.json';\nimport { version as pluginOrg } from '../../../../plugins/org/package.json';\nimport { version as pluginPermissionCommon } from '../../../../plugins/permission-common/package.json';\nimport { version as pluginPermissionNode } from '../../../../plugins/permission-node/package.json';\nimport { version as pluginProxyBackend } from '../../../../plugins/proxy-backend/package.json';\nimport { version as pluginRollbarBackend } from '../../../../plugins/rollbar-backend/package.json';\nimport { version as pluginScaffolder } from '../../../../plugins/scaffolder/package.json';\nimport { version as pluginScaffolderBackend } from '../../../../plugins/scaffolder-backend/package.json';\nimport { version as pluginSearch } from '../../../../plugins/search/package.json';\nimport { version as pluginSearchBackend } from '../../../../plugins/search-backend/package.json';\nimport { version as pluginSearchBackendNode } from '../../../../plugins/search-backend-node/package.json';\nimport { version as pluginTechRadar } from '../../../../plugins/tech-radar/package.json';\nimport { version as pluginTechdocs } from '../../../../plugins/techdocs/package.json';\nimport { version as pluginTechdocsBackend } from '../../../../plugins/techdocs-backend/package.json';\nimport { version as pluginUserSettings } from '../../../../plugins/user-settings/package.json';\n\nexport const packageVersions = {\n '@backstage/app-defaults': appDefaults,\n '@backstage/backend-common': backendCommon,\n '@backstage/backend-tasks': backendTasks,\n '@backstage/catalog-client': catalogClient,\n '@backstage/catalog-model': catalogModel,\n '@backstage/cli': cli,\n '@backstage/config': config,\n '@backstage/core-app-api': coreAppApi,\n '@backstage/core-components': coreComponents,\n '@backstage/core-plugin-api': corePluginApi,\n '@backstage/errors': errors,\n '@backstage/integration-react': integrationReact,\n '@backstage/plugin-api-docs': pluginApiDocs,\n '@backstage/plugin-app-backend': pluginAppBackend,\n '@backstage/plugin-auth-backend': pluginAuthBackend,\n '@backstage/plugin-catalog': pluginCatalog,\n '@backstage/plugin-catalog-react': pluginCatalogReact,\n '@backstage/plugin-catalog-backend': pluginCatalogBackend,\n '@backstage/plugin-catalog-import': pluginCatalogImport,\n '@backstage/plugin-circleci': pluginCircleci,\n '@backstage/plugin-explore': pluginExplore,\n '@backstage/plugin-github-actions': pluginGithubActions,\n '@backstage/plugin-lighthouse': pluginLighthouse,\n '@backstage/plugin-org': pluginOrg,\n '@backstage/plugin-permission-common': pluginPermissionCommon,\n '@backstage/plugin-permission-node': pluginPermissionNode,\n '@backstage/plugin-proxy-backend': pluginProxyBackend,\n '@backstage/plugin-rollbar-backend': pluginRollbarBackend,\n '@backstage/plugin-scaffolder': pluginScaffolder,\n '@backstage/plugin-scaffolder-backend': pluginScaffolderBackend,\n '@backstage/plugin-search': pluginSearch,\n '@backstage/plugin-search-backend': pluginSearchBackend,\n '@backstage/plugin-search-backend-node': pluginSearchBackendNode,\n '@backstage/plugin-tech-radar': pluginTechRadar,\n '@backstage/plugin-techdocs': pluginTechdocs,\n '@backstage/plugin-techdocs-backend': pluginTechdocsBackend,\n '@backstage/plugin-user-settings': pluginUserSettings,\n '@backstage/test-utils': testUtils,\n '@backstage/theme': theme,\n};\n","/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { BACKSTAGE_JSON } from '@backstage/cli-common';\nimport chalk from 'chalk';\nimport fs from 'fs-extra';\nimport handlebars from 'handlebars';\nimport ora from 'ora';\nimport recursive from 'recursive-readdir';\nimport {\n basename,\n dirname,\n join,\n resolve as resolvePath,\n relative as relativePath,\n} from 'path';\nimport { exec as execCb } from 'child_process';\nimport { packageVersions } from './versions';\nimport { promisify } from 'util';\n\nconst TASK_NAME_MAX_LENGTH = 14;\nconst exec = promisify(execCb);\n\nexport class Task {\n static log(name: string = '') {\n process.stdout.write(`${chalk.green(name)}\\n`);\n }\n\n static error(message: string = '') {\n process.stdout.write(`\\n${chalk.red(message)}\\n\\n`);\n }\n\n static section(name: string) {\n const title = chalk.green(`${name}:`);\n process.stdout.write(`\\n ${title}\\n`);\n }\n\n static exit(code: number = 0) {\n process.exit(code);\n }\n\n static async forItem(\n task: string,\n item: string,\n taskFunc: () => Promise<void>,\n ): Promise<void> {\n const paddedTask = chalk.green(task.padEnd(TASK_NAME_MAX_LENGTH));\n\n const spinner = ora({\n prefixText: chalk.green(` ${paddedTask}${chalk.cyan(item)}`),\n spinner: 'arc',\n color: 'green',\n }).start();\n\n try {\n await taskFunc();\n spinner.succeed();\n } catch (error) {\n spinner.fail();\n throw error;\n }\n }\n}\n\n/**\n * Generate a templated backstage project\n *\n * @param templateDir - location containing template files\n * @param destinationDir - location to save templated project\n * @param context - template parameters\n */\nexport async function templatingTask(\n templateDir: string,\n destinationDir: string,\n context: any,\n version: string,\n) {\n const files = await recursive(templateDir).catch(error => {\n throw new Error(`Failed to read template directory: ${error.message}`);\n });\n\n for (const file of files) {\n const destinationFile = resolvePath(\n destinationDir,\n relativePath(templateDir, file),\n );\n await fs.ensureDir(dirname(destinationFile));\n\n if (file.endsWith('.hbs')) {\n await Task.forItem('templating', basename(file), async () => {\n const destination = destinationFile.replace(/\\.hbs$/, '');\n\n const template = await fs.readFile(file);\n const compiled = handlebars.compile(template.toString());\n const contents = compiled(\n { name: basename(destination), ...context },\n {\n helpers: {\n version(name: keyof typeof packageVersions) {\n if (name in packageVersions) {\n return packageVersions[name];\n }\n throw new Error(`No version available for package ${name}`);\n },\n },\n },\n );\n\n await fs.writeFile(destination, contents).catch(error => {\n throw new Error(\n `Failed to create file: ${destination}: ${error.message}`,\n );\n });\n });\n } else {\n await Task.forItem('copying', basename(file), async () => {\n await fs.copyFile(file, destinationFile).catch(error => {\n const destination = destinationFile;\n throw new Error(\n `Failed to copy file to ${destination} : ${error.message}`,\n );\n });\n });\n }\n }\n await Task.forItem('creating', BACKSTAGE_JSON, () =>\n fs.writeFile(\n join(destinationDir, BACKSTAGE_JSON),\n `{\\n \"version\": ${JSON.stringify(version)}\\n}\\n`,\n ),\n );\n}\n\n/**\n * Verify that application target does not already exist\n *\n * @param rootDir - The directory to create application folder `name`\n * @param name - The specified name of the application\n * @Throws Error - If directory with name of `destination` already exists\n */\nexport async function checkAppExistsTask(rootDir: string, name: string) {\n await Task.forItem('checking', name, async () => {\n const destination = resolvePath(rootDir, name);\n\n if (await fs.pathExists(destination)) {\n const existing = chalk.cyan(destination.replace(`${rootDir}/`, ''));\n throw new Error(\n `A directory with the same name already exists: ${existing}\\nPlease try again with a different app name`,\n );\n }\n });\n}\n\n/**\n * Verify that application `path` exists, otherwise create the directory\n *\n * @param path - target to create directory\n * @throws if `path` is a file, or `fs.mkdir` fails\n */\nexport async function checkPathExistsTask(path: string) {\n await Task.forItem('checking', path, async () => {\n try {\n await fs.mkdirs(path);\n } catch (error) {\n // will fail if a file already exists at given `path`\n throw new Error(`Failed to create app directory: ${error.message}`);\n }\n });\n}\n\n/**\n * Create a folder to store templated files\n *\n * @param tempDir - target temporary directory\n * @throws if `fs.mkdir` fails\n */\nexport async function createTemporaryAppFolderTask(tempDir: string) {\n await Task.forItem('creating', 'temporary directory', async () => {\n try {\n await fs.mkdir(tempDir);\n } catch (error) {\n throw new Error(`Failed to create temporary app directory, ${error}`);\n }\n });\n}\n\n/**\n * Run `yarn install` and `run tsc` in application directory\n *\n * @param appDir - location of application to build\n */\nexport async function buildAppTask(appDir: string) {\n const runCmd = async (cmd: string) => {\n await Task.forItem('executing', cmd, async () => {\n process.chdir(appDir);\n await exec(cmd).catch(error => {\n process.stdout.write(error.stderr);\n process.stdout.write(error.stdout);\n throw new Error(`Could not execute command ${chalk.cyan(cmd)}`);\n });\n });\n };\n\n await runCmd('yarn install');\n await runCmd('yarn tsc');\n}\n\n/**\n * Move temporary directory to destination application folder\n *\n * @param tempDir - source path to copy files from\n * @param destination - target path to copy files\n * @param id - item ID\n * @throws if `fs.move` fails\n */\nexport async function moveAppTask(\n tempDir: string,\n destination: string,\n id: string,\n) {\n await Task.forItem('moving', id, async () => {\n await fs\n .move(tempDir, destination)\n .catch(error => {\n throw new Error(\n `Failed to move app from ${tempDir} to ${destination}: ${error.message}`,\n );\n })\n .finally(() => {\n // remove temporary files on both success and failure\n fs.removeSync(tempDir);\n });\n });\n}\n","/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport chalk from 'chalk';\nimport { Command } from 'commander';\nimport inquirer, { Answers, Question } from 'inquirer';\nimport { resolve as resolvePath } from 'path';\nimport { findPaths } from '@backstage/cli-common';\nimport os from 'os';\nimport {\n Task,\n buildAppTask,\n checkAppExistsTask,\n checkPathExistsTask,\n createTemporaryAppFolderTask,\n moveAppTask,\n templatingTask,\n} from './lib/tasks';\n\nexport default async (cmd: Command, version: string): Promise<void> => {\n /* eslint-disable-next-line no-restricted-syntax */\n const paths = findPaths(__dirname);\n\n const questions: Question[] = [\n {\n type: 'input',\n name: 'name',\n message: chalk.blue('Enter a name for the app [required]'),\n validate: (value: any) => {\n if (!value) {\n return chalk.red('Please enter a name for the app');\n } else if (!/^[a-z0-9]+(-[a-z0-9]+)*$/.test(value)) {\n return chalk.red(\n 'App name must be lowercase and contain only letters, digits, and dashes.',\n );\n }\n return true;\n },\n },\n {\n type: 'list',\n name: 'dbType',\n message: chalk.blue('Select database for the backend [required]'),\n // @ts-ignore\n choices: ['SQLite', 'PostgreSQL'],\n },\n ];\n const answers: Answers = await inquirer.prompt(questions);\n answers.dbTypePG = answers.dbType === 'PostgreSQL';\n answers.dbTypeSqlite = answers.dbType === 'SQLite';\n\n const templateDir = paths.resolveOwn('templates/default-app');\n const tempDir = resolvePath(os.tmpdir(), answers.name);\n\n // Use `--path` argument as application directory when specified, otherwise\n // create a directory using `answers.name`\n const appDir = cmd.path\n ? resolvePath(paths.targetDir, cmd.path)\n : resolvePath(paths.targetDir, answers.name);\n\n Task.log();\n Task.log('Creating the app...');\n\n try {\n if (cmd.path) {\n // Template directly to specified path\n\n Task.section('Checking that supplied path exists');\n await checkPathExistsTask(appDir);\n\n Task.section('Preparing files');\n await templatingTask(templateDir, cmd.path, answers, version);\n } else {\n // Template to temporary location, and then move files\n\n Task.section('Checking if the directory is available');\n await checkAppExistsTask(paths.targetDir, answers.name);\n\n Task.section('Creating a temporary app directory');\n await createTemporaryAppFolderTask(tempDir);\n\n Task.section('Preparing files');\n await templatingTask(templateDir, tempDir, answers, version);\n\n Task.section('Moving to final location');\n await moveAppTask(tempDir, appDir, answers.name);\n }\n\n if (!cmd.skipInstall) {\n Task.section('Building the app');\n await buildAppTask(appDir);\n }\n\n Task.log();\n Task.log(\n chalk.green(`🥇 Successfully created ${chalk.cyan(answers.name)}`),\n );\n Task.log();\n Task.section('All set! Now you might want to');\n Task.log(` Run the app: ${chalk.cyan(`cd ${answers.name} && yarn dev`)}`);\n Task.log(\n ' Set up the software catalog: https://backstage.io/docs/features/software-catalog/configuration',\n );\n Task.log(' Add authentication: https://backstage.io/docs/auth/');\n Task.log();\n Task.exit();\n } catch (error) {\n Task.error(String(error));\n\n Task.log('It seems that something went wrong when creating the app 🤔');\n\n Task.error('🔥 Failed to create app!');\n Task.exit(1);\n }\n};\n","/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * A CLI that helps you create your own Backstage app\n *\n * @packageDocumentation\n */\n\nimport program from 'commander';\nimport { exitWithError } from './lib/errors';\nimport { version } from '../package.json';\nimport createApp from './createApp';\n\nconst main = (argv: string[]) => {\n program\n .name('backstage-create-app')\n .version(version)\n .description('Creates a new app in a new directory or specified path')\n .option(\n '--path [directory]',\n 'Location to store the app defaulting to a new folder with the app name',\n )\n .option(\n '--skip-install',\n 'Skip the install and builds steps after creating the app',\n )\n .action(cmd => createApp(cmd, version));\n\n program.parse(argv);\n};\n\nprocess.on('unhandledRejection', rejection => {\n if (rejection instanceof Error) {\n exitWithError(rejection);\n } else {\n exitWithError(new Error(`Unknown rejection: '${rejection}'`));\n }\n});\n\nmain(process.argv);\n"],"names":["chalk","appDefaults","backendCommon","backendTasks","catalogClient","catalogModel","cli","config","coreAppApi","coreComponents","corePluginApi","errors","integrationReact","pluginApiDocs","pluginAppBackend","pluginAuthBackend","pluginCatalog","pluginCatalogReact","pluginCatalogBackend","pluginCatalogImport","pluginCircleci","pluginExplore","pluginGithubActions","pluginLighthouse","pluginOrg","pluginPermissionCommon","pluginPermissionNode","pluginProxyBackend","pluginRollbarBackend","pluginScaffolder","pluginScaffolderBackend","pluginSearch","pluginSearchBackend","pluginSearchBackendNode","pluginTechRadar","pluginTechdocs","pluginTechdocsBackend","pluginUserSettings","testUtils","theme","promisify","execCb","ora","recursive","resolvePath","relativePath","fs","dirname","basename","handlebars","BACKSTAGE_JSON","join","findPaths","inquirer","os","version"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;0BAkBiC,MAAM;AAAA,MACjC,OAAe;AACjB,WAAO,KAAK,YAAY;AAAA;AAAA;4BAIO,YAAY;AAAA,EAG7C,YAAY,MAAc,SAAkB;AAC1C,QAAI,SAAS;AACX,YAAM,YAAY,6BAA6B;AAAA,WAC1C;AACL,YAAM,0BAA0B;AAAA;AAElC,SAAK,OAAO;AAAA;AAAA;uBAIc,OAAqB;AACjD,MAAI,iBAAiB,eAAe;AAClC,YAAQ,OAAO,MAAM;AAAA,EAAKA,0BAAM,IAAI,MAAM;AAAA;AAAA;AAC1C,YAAQ,KAAK,MAAM;AAAA,SACd;AACL,YAAQ,OAAO,MAAM;AAAA,EAAKA,0BAAM,IAAI,GAAG;AAAA;AAAA;AACvC,YAAQ,KAAK;AAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MC8BJ,kBAAkB;AAAA,EAC7B,2BAA2BC;AAAA,EAC3B,6BAA6BC;AAAA,EAC7B,4BAA4BC;AAAA,EAC5B,6BAA6BC;AAAA,EAC7B,4BAA4BC;AAAA,EAC5B,kBAAkBC;AAAA,EAClB,qBAAqBC;AAAA,EACrB,2BAA2BC;AAAA,EAC3B,8BAA8BC;AAAA,EAC9B,8BAA8BC;AAAA,EAC9B,qBAAqBC;AAAA,EACrB,gCAAgCC;AAAA,EAChC,8BAA8BC;AAAA,EAC9B,iCAAiCC;AA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ACE,OAAP;AACA,SAAK,MAAM,OAAO;AAElB,SAAK,IAAI;AAET,SAAK,MAAM;AACX,SAAK,KAAK;AAAA;AAAA;;AClGd,MAAM,OAAO,CAAC,SAAmB;AAC/B,8BACG,KAAK,wBACL,QAAQuD,WACR,YAAY,0DACZ,OACC,sBACA,0EAED,OACC,kBACA,4DAED,OAAO,SAAO,UAAU,KAAKA;AAEhC,8BAAQ,MAAM;AAAA;AAGhB,QAAQ,GAAG,sBAAsB,eAAa;AAC5C,MAAI,qBAAqB,OAAO;AAC9B,kBAAc;AAAA,SACT;AACL,kBAAc,IAAI,MAAM,uBAAuB;AAAA;AAAA;AAInD,KAAK,QAAQ;;"}
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":["../src/lib/errors.ts","../src/lib/versions.ts","../src/lib/tasks.ts","../src/createApp.ts","../src/index.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport chalk from 'chalk';\n\nexport class CustomError extends Error {\n get name(): string {\n return this.constructor.name;\n }\n}\n\nexport class ExitCodeError extends CustomError {\n readonly code: number;\n\n constructor(code: number, command?: string) {\n if (command) {\n super(`Command '${command}' exited with code ${code}`);\n } else {\n super(`Child exited with code ${code}`);\n }\n this.code = code;\n }\n}\n\nexport function exitWithError(error: Error): never {\n if (error instanceof ExitCodeError) {\n process.stderr.write(`\\n${chalk.red(error.message)}\\n\\n`);\n process.exit(error.code);\n } else {\n process.stderr.write(`\\n${chalk.red(`${error}`)}\\n\\n`);\n process.exit(1);\n }\n}\n","/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/* eslint-disable monorepo/no-relative-import */\n\n/*\nThis is a list of all packages used by the template. If dependencies are added or removed,\nthis list should be updated as well.\n\nThe list, and the accompanying peerDependencies entries, are here to ensure correct versioning\nand bumping of this package. Without this list the version would not be bumped unless we\nmanually trigger a release.\n\nThis does not create an actual dependency on these packages and does not bring in any code.\nRelative imports are used rather than package imports to make sure the packages aren't externalized.\nRollup will extract the value of the version field in each package at build time without\nleaving any imports in place.\n*/\n\nimport { version as appDefaults } from '../../../app-defaults/package.json';\nimport { version as backendCommon } from '../../../backend-common/package.json';\nimport { version as backendTasks } from '../../../backend-tasks/package.json';\nimport { version as catalogClient } from '../../../catalog-client/package.json';\nimport { version as catalogModel } from '../../../catalog-model/package.json';\nimport { version as cli } from '../../../cli/package.json';\nimport { version as config } from '../../../config/package.json';\nimport { version as coreAppApi } from '../../../core-app-api/package.json';\nimport { version as coreComponents } from '../../../core-components/package.json';\nimport { version as corePluginApi } from '../../../core-plugin-api/package.json';\nimport { version as errors } from '../../../errors/package.json';\nimport { version as integrationReact } from '../../../integration-react/package.json';\nimport { version as testUtils } from '../../../test-utils/package.json';\nimport { version as theme } from '../../../theme/package.json';\n\nimport { version as pluginApiDocs } from '../../../../plugins/api-docs/package.json';\nimport { version as pluginAppBackend } from '../../../../plugins/app-backend/package.json';\nimport { version as pluginAuthBackend } from '../../../../plugins/auth-backend/package.json';\nimport { version as pluginCatalog } from '../../../../plugins/catalog/package.json';\nimport { version as pluginCatalogReact } from '../../../../plugins/catalog-react/package.json';\nimport { version as pluginCatalogBackend } from '../../../../plugins/catalog-backend/package.json';\nimport { version as pluginCatalogGraph } from '../../../../plugins/catalog-graph/package.json';\nimport { version as pluginCatalogImport } from '../../../../plugins/catalog-import/package.json';\nimport { version as pluginCircleci } from '../../../../plugins/circleci/package.json';\nimport { version as pluginExplore } from '../../../../plugins/explore/package.json';\nimport { version as pluginGithubActions } from '../../../../plugins/github-actions/package.json';\nimport { version as pluginLighthouse } from '../../../../plugins/lighthouse/package.json';\nimport { version as pluginOrg } from '../../../../plugins/org/package.json';\nimport { version as pluginPermissionCommon } from '../../../../plugins/permission-common/package.json';\nimport { version as pluginPermissionNode } from '../../../../plugins/permission-node/package.json';\nimport { version as pluginProxyBackend } from '../../../../plugins/proxy-backend/package.json';\nimport { version as pluginRollbarBackend } from '../../../../plugins/rollbar-backend/package.json';\nimport { version as pluginScaffolder } from '../../../../plugins/scaffolder/package.json';\nimport { version as pluginScaffolderBackend } from '../../../../plugins/scaffolder-backend/package.json';\nimport { version as pluginSearch } from '../../../../plugins/search/package.json';\nimport { version as pluginSearchBackend } from '../../../../plugins/search-backend/package.json';\nimport { version as pluginSearchBackendNode } from '../../../../plugins/search-backend-node/package.json';\nimport { version as pluginTechRadar } from '../../../../plugins/tech-radar/package.json';\nimport { version as pluginTechdocs } from '../../../../plugins/techdocs/package.json';\nimport { version as pluginTechdocsBackend } from '../../../../plugins/techdocs-backend/package.json';\nimport { version as pluginUserSettings } from '../../../../plugins/user-settings/package.json';\n\nexport const packageVersions = {\n '@backstage/app-defaults': appDefaults,\n '@backstage/backend-common': backendCommon,\n '@backstage/backend-tasks': backendTasks,\n '@backstage/catalog-client': catalogClient,\n '@backstage/catalog-model': catalogModel,\n '@backstage/cli': cli,\n '@backstage/config': config,\n '@backstage/core-app-api': coreAppApi,\n '@backstage/core-components': coreComponents,\n '@backstage/core-plugin-api': corePluginApi,\n '@backstage/errors': errors,\n '@backstage/integration-react': integrationReact,\n '@backstage/plugin-api-docs': pluginApiDocs,\n '@backstage/plugin-app-backend': pluginAppBackend,\n '@backstage/plugin-auth-backend': pluginAuthBackend,\n '@backstage/plugin-catalog': pluginCatalog,\n '@backstage/plugin-catalog-react': pluginCatalogReact,\n '@backstage/plugin-catalog-backend': pluginCatalogBackend,\n '@backstage/plugin-catalog-graph': pluginCatalogGraph,\n '@backstage/plugin-catalog-import': pluginCatalogImport,\n '@backstage/plugin-circleci': pluginCircleci,\n '@backstage/plugin-explore': pluginExplore,\n '@backstage/plugin-github-actions': pluginGithubActions,\n '@backstage/plugin-lighthouse': pluginLighthouse,\n '@backstage/plugin-org': pluginOrg,\n '@backstage/plugin-permission-common': pluginPermissionCommon,\n '@backstage/plugin-permission-node': pluginPermissionNode,\n '@backstage/plugin-proxy-backend': pluginProxyBackend,\n '@backstage/plugin-rollbar-backend': pluginRollbarBackend,\n '@backstage/plugin-scaffolder': pluginScaffolder,\n '@backstage/plugin-scaffolder-backend': pluginScaffolderBackend,\n '@backstage/plugin-search': pluginSearch,\n '@backstage/plugin-search-backend': pluginSearchBackend,\n '@backstage/plugin-search-backend-node': pluginSearchBackendNode,\n '@backstage/plugin-tech-radar': pluginTechRadar,\n '@backstage/plugin-techdocs': pluginTechdocs,\n '@backstage/plugin-techdocs-backend': pluginTechdocsBackend,\n '@backstage/plugin-user-settings': pluginUserSettings,\n '@backstage/test-utils': testUtils,\n '@backstage/theme': theme,\n};\n","/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { BACKSTAGE_JSON } from '@backstage/cli-common';\nimport chalk from 'chalk';\nimport fs from 'fs-extra';\nimport handlebars from 'handlebars';\nimport ora from 'ora';\nimport recursive from 'recursive-readdir';\nimport {\n basename,\n dirname,\n join,\n resolve as resolvePath,\n relative as relativePath,\n} from 'path';\nimport { exec as execCb } from 'child_process';\nimport { packageVersions } from './versions';\nimport { promisify } from 'util';\n\nconst TASK_NAME_MAX_LENGTH = 14;\nconst exec = promisify(execCb);\n\nexport class Task {\n static log(name: string = '') {\n process.stdout.write(`${chalk.green(name)}\\n`);\n }\n\n static error(message: string = '') {\n process.stdout.write(`\\n${chalk.red(message)}\\n\\n`);\n }\n\n static section(name: string) {\n const title = chalk.green(`${name}:`);\n process.stdout.write(`\\n ${title}\\n`);\n }\n\n static exit(code: number = 0) {\n process.exit(code);\n }\n\n static async forItem(\n task: string,\n item: string,\n taskFunc: () => Promise<void>,\n ): Promise<void> {\n const paddedTask = chalk.green(task.padEnd(TASK_NAME_MAX_LENGTH));\n\n const spinner = ora({\n prefixText: chalk.green(` ${paddedTask}${chalk.cyan(item)}`),\n spinner: 'arc',\n color: 'green',\n }).start();\n\n try {\n await taskFunc();\n spinner.succeed();\n } catch (error) {\n spinner.fail();\n throw error;\n }\n }\n}\n\n/**\n * Generate a templated backstage project\n *\n * @param templateDir - location containing template files\n * @param destinationDir - location to save templated project\n * @param context - template parameters\n */\nexport async function templatingTask(\n templateDir: string,\n destinationDir: string,\n context: any,\n version: string,\n) {\n const files = await recursive(templateDir).catch(error => {\n throw new Error(`Failed to read template directory: ${error.message}`);\n });\n\n for (const file of files) {\n const destinationFile = resolvePath(\n destinationDir,\n relativePath(templateDir, file),\n );\n await fs.ensureDir(dirname(destinationFile));\n\n if (file.endsWith('.hbs')) {\n await Task.forItem('templating', basename(file), async () => {\n const destination = destinationFile.replace(/\\.hbs$/, '');\n\n const template = await fs.readFile(file);\n const compiled = handlebars.compile(template.toString());\n const contents = compiled(\n { name: basename(destination), ...context },\n {\n helpers: {\n version(name: keyof typeof packageVersions) {\n if (name in packageVersions) {\n return packageVersions[name];\n }\n throw new Error(`No version available for package ${name}`);\n },\n },\n },\n );\n\n await fs.writeFile(destination, contents).catch(error => {\n throw new Error(\n `Failed to create file: ${destination}: ${error.message}`,\n );\n });\n });\n } else {\n await Task.forItem('copying', basename(file), async () => {\n await fs.copyFile(file, destinationFile).catch(error => {\n const destination = destinationFile;\n throw new Error(\n `Failed to copy file to ${destination} : ${error.message}`,\n );\n });\n });\n }\n }\n await Task.forItem('creating', BACKSTAGE_JSON, () =>\n fs.writeFile(\n join(destinationDir, BACKSTAGE_JSON),\n `{\\n \"version\": ${JSON.stringify(version)}\\n}\\n`,\n ),\n );\n}\n\n/**\n * Verify that application target does not already exist\n *\n * @param rootDir - The directory to create application folder `name`\n * @param name - The specified name of the application\n * @Throws Error - If directory with name of `destination` already exists\n */\nexport async function checkAppExistsTask(rootDir: string, name: string) {\n await Task.forItem('checking', name, async () => {\n const destination = resolvePath(rootDir, name);\n\n if (await fs.pathExists(destination)) {\n const existing = chalk.cyan(destination.replace(`${rootDir}/`, ''));\n throw new Error(\n `A directory with the same name already exists: ${existing}\\nPlease try again with a different app name`,\n );\n }\n });\n}\n\n/**\n * Verify that application `path` exists, otherwise create the directory\n *\n * @param path - target to create directory\n * @throws if `path` is a file, or `fs.mkdir` fails\n */\nexport async function checkPathExistsTask(path: string) {\n await Task.forItem('checking', path, async () => {\n try {\n await fs.mkdirs(path);\n } catch (error) {\n // will fail if a file already exists at given `path`\n throw new Error(`Failed to create app directory: ${error.message}`);\n }\n });\n}\n\n/**\n * Create a folder to store templated files\n *\n * @param tempDir - target temporary directory\n * @throws if `fs.mkdir` fails\n */\nexport async function createTemporaryAppFolderTask(tempDir: string) {\n await Task.forItem('creating', 'temporary directory', async () => {\n try {\n await fs.mkdir(tempDir);\n } catch (error) {\n throw new Error(`Failed to create temporary app directory, ${error}`);\n }\n });\n}\n\n/**\n * Run `yarn install` and `run tsc` in application directory\n *\n * @param appDir - location of application to build\n */\nexport async function buildAppTask(appDir: string) {\n const runCmd = async (cmd: string) => {\n await Task.forItem('executing', cmd, async () => {\n process.chdir(appDir);\n await exec(cmd).catch(error => {\n process.stdout.write(error.stderr);\n process.stdout.write(error.stdout);\n throw new Error(`Could not execute command ${chalk.cyan(cmd)}`);\n });\n });\n };\n\n await runCmd('yarn install');\n await runCmd('yarn tsc');\n}\n\n/**\n * Move temporary directory to destination application folder\n *\n * @param tempDir - source path to copy files from\n * @param destination - target path to copy files\n * @param id - item ID\n * @throws if `fs.move` fails\n */\nexport async function moveAppTask(\n tempDir: string,\n destination: string,\n id: string,\n) {\n await Task.forItem('moving', id, async () => {\n await fs\n .move(tempDir, destination)\n .catch(error => {\n throw new Error(\n `Failed to move app from ${tempDir} to ${destination}: ${error.message}`,\n );\n })\n .finally(() => {\n // remove temporary files on both success and failure\n fs.removeSync(tempDir);\n });\n });\n}\n","/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport chalk from 'chalk';\nimport { Command } from 'commander';\nimport inquirer, { Answers } from 'inquirer';\nimport { resolve as resolvePath } from 'path';\nimport { findPaths } from '@backstage/cli-common';\nimport os from 'os';\nimport {\n Task,\n buildAppTask,\n checkAppExistsTask,\n checkPathExistsTask,\n createTemporaryAppFolderTask,\n moveAppTask,\n templatingTask,\n} from './lib/tasks';\n\nexport default async (cmd: Command, version: string): Promise<void> => {\n /* eslint-disable-next-line no-restricted-syntax */\n const paths = findPaths(__dirname);\n\n const answers: Answers = await inquirer.prompt([\n {\n type: 'input',\n name: 'name',\n message: chalk.blue('Enter a name for the app [required]'),\n validate: (value: any) => {\n if (!value) {\n return chalk.red('Please enter a name for the app');\n } else if (!/^[a-z0-9]+(-[a-z0-9]+)*$/.test(value)) {\n return chalk.red(\n 'App name must be lowercase and contain only letters, digits, and dashes.',\n );\n }\n return true;\n },\n },\n {\n type: 'list',\n name: 'dbType',\n message: chalk.blue('Select database for the backend [required]'),\n choices: ['SQLite', 'PostgreSQL'],\n },\n ]);\n answers.dbTypePG = answers.dbType === 'PostgreSQL';\n answers.dbTypeSqlite = answers.dbType === 'SQLite';\n\n const templateDir = paths.resolveOwn('templates/default-app');\n const tempDir = resolvePath(os.tmpdir(), answers.name);\n\n // Use `--path` argument as application directory when specified, otherwise\n // create a directory using `answers.name`\n const appDir = cmd.path\n ? resolvePath(paths.targetDir, cmd.path)\n : resolvePath(paths.targetDir, answers.name);\n\n Task.log();\n Task.log('Creating the app...');\n\n try {\n if (cmd.path) {\n // Template directly to specified path\n\n Task.section('Checking that supplied path exists');\n await checkPathExistsTask(appDir);\n\n Task.section('Preparing files');\n await templatingTask(templateDir, cmd.path, answers, version);\n } else {\n // Template to temporary location, and then move files\n\n Task.section('Checking if the directory is available');\n await checkAppExistsTask(paths.targetDir, answers.name);\n\n Task.section('Creating a temporary app directory');\n await createTemporaryAppFolderTask(tempDir);\n\n Task.section('Preparing files');\n await templatingTask(templateDir, tempDir, answers, version);\n\n Task.section('Moving to final location');\n await moveAppTask(tempDir, appDir, answers.name);\n }\n\n if (!cmd.skipInstall) {\n Task.section('Building the app');\n await buildAppTask(appDir);\n }\n\n Task.log();\n Task.log(\n chalk.green(`🥇 Successfully created ${chalk.cyan(answers.name)}`),\n );\n Task.log();\n Task.section('All set! Now you might want to');\n Task.log(` Run the app: ${chalk.cyan(`cd ${answers.name} && yarn dev`)}`);\n Task.log(\n ' Set up the software catalog: https://backstage.io/docs/features/software-catalog/configuration',\n );\n Task.log(' Add authentication: https://backstage.io/docs/auth/');\n Task.log();\n Task.exit();\n } catch (error) {\n Task.error(String(error));\n\n Task.log('It seems that something went wrong when creating the app 🤔');\n\n Task.error('🔥 Failed to create app!');\n Task.exit(1);\n }\n};\n","/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * A CLI that helps you create your own Backstage app\n *\n * @packageDocumentation\n */\n\nimport program from 'commander';\nimport { exitWithError } from './lib/errors';\nimport { version } from '../package.json';\nimport createApp from './createApp';\n\nconst main = (argv: string[]) => {\n program\n .name('backstage-create-app')\n .version(version)\n .description('Creates a new app in a new directory or specified path')\n .option(\n '--path [directory]',\n 'Location to store the app defaulting to a new folder with the app name',\n )\n .option(\n '--skip-install',\n 'Skip the install and builds steps after creating the app',\n )\n .action(cmd => createApp(cmd, version));\n\n program.parse(argv);\n};\n\nprocess.on('unhandledRejection', rejection => {\n if (rejection instanceof Error) {\n exitWithError(rejection);\n } else {\n exitWithError(new Error(`Unknown rejection: '${rejection}'`));\n }\n});\n\nmain(process.argv);\n"],"names":["chalk","appDefaults","backendCommon","backendTasks","catalogClient","catalogModel","cli","config","coreAppApi","coreComponents","corePluginApi","errors","integrationReact","pluginApiDocs","pluginAppBackend","pluginAuthBackend","pluginCatalog","pluginCatalogReact","pluginCatalogBackend","pluginCatalogGraph","pluginCatalogImport","pluginCircleci","pluginExplore","pluginGithubActions","pluginLighthouse","pluginOrg","pluginPermissionCommon","pluginPermissionNode","pluginProxyBackend","pluginRollbarBackend","pluginScaffolder","pluginScaffolderBackend","pluginSearch","pluginSearchBackend","pluginSearchBackendNode","pluginTechRadar","pluginTechdocs","pluginTechdocsBackend","pluginUserSettings","testUtils","theme","promisify","execCb","ora","recursive","resolvePath","relativePath","fs","dirname","basename","handlebars","BACKSTAGE_JSON","join","findPaths","inquirer","os","version"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;0BAkB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O;AAC9B,kBAAc;AAAA,SACT;AACL,kBAAc,IAAI,MAAM,uBAAuB;AAAA;AAAA;AAInD,KAAK,QAAQ;;"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/create-app",
|
|
3
3
|
"description": "A CLI that helps you create your own Backstage app",
|
|
4
|
-
"version": "0.4.
|
|
4
|
+
"version": "0.4.18-next.0",
|
|
5
5
|
"private": false,
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -57,5 +57,5 @@
|
|
|
57
57
|
"dist",
|
|
58
58
|
"templates"
|
|
59
59
|
],
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "a28838ac5c80c7332caa6ca0569d2ec85151784f"
|
|
61
61
|
}
|
|
@@ -7,7 +7,8 @@ organization:
|
|
|
7
7
|
|
|
8
8
|
backend:
|
|
9
9
|
# Used for enabling authentication, secret is shared by all backend plugins
|
|
10
|
-
# See backend-to-backend-auth
|
|
10
|
+
# See https://backstage.io/docs/tutorials/backend-to-backend-auth for
|
|
11
|
+
# information on the format
|
|
11
12
|
# auth:
|
|
12
13
|
# keys:
|
|
13
14
|
# - secret: ${BACKEND_SECRET}
|
|
@@ -80,6 +81,9 @@ scaffolder:
|
|
|
80
81
|
# see https://backstage.io/docs/features/software-templates/configuration for software template options
|
|
81
82
|
|
|
82
83
|
catalog:
|
|
84
|
+
import:
|
|
85
|
+
entityFilename: catalog-info.yaml
|
|
86
|
+
pullRequestBranchName: backstage-integration
|
|
83
87
|
rules:
|
|
84
88
|
- allow: [Component, System, API, Group, User, Resource, Location]
|
|
85
89
|
locations:
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"@backstage/integration-react": "^{{version '@backstage/integration-react'}}",
|
|
14
14
|
"@backstage/plugin-api-docs": "^{{version '@backstage/plugin-api-docs'}}",
|
|
15
15
|
"@backstage/plugin-catalog": "^{{version '@backstage/plugin-catalog'}}",
|
|
16
|
+
"@backstage/plugin-catalog-graph": "^{{version '@backstage/plugin-catalog-graph'}}",
|
|
16
17
|
"@backstage/plugin-catalog-import": "^{{version '@backstage/plugin-catalog-import'}}",
|
|
17
18
|
"@backstage/plugin-catalog-react": "^{{version '@backstage/plugin-catalog-react'}}",
|
|
18
19
|
"@backstage/plugin-github-actions": "^{{version '@backstage/plugin-github-actions'}}",
|
|
@@ -26,8 +27,8 @@
|
|
|
26
27
|
"@material-ui/core": "^4.12.2",
|
|
27
28
|
"@material-ui/icons": "^4.9.1",
|
|
28
29
|
"history": "^5.0.0",
|
|
29
|
-
"react": "^
|
|
30
|
-
"react-dom": "^
|
|
30
|
+
"react": "^17.0.2",
|
|
31
|
+
"react-dom": "^17.0.2",
|
|
31
32
|
"react-router": "6.0.0-beta.0",
|
|
32
33
|
"react-router-dom": "6.0.0-beta.0",
|
|
33
34
|
"react-use": "^15.3.3"
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
catalogImportPlugin,
|
|
12
12
|
} from '@backstage/plugin-catalog-import';
|
|
13
13
|
import { ScaffolderPage, scaffolderPlugin } from '@backstage/plugin-scaffolder';
|
|
14
|
+
import { orgPlugin } from '@backstage/plugin-org';
|
|
14
15
|
import { SearchPage } from '@backstage/plugin-search';
|
|
15
16
|
import { TechRadarPage } from '@backstage/plugin-tech-radar';
|
|
16
17
|
import {
|
|
@@ -28,6 +29,7 @@ import { Root } from './components/Root';
|
|
|
28
29
|
import { AlertDisplay, OAuthRequestDialog } from '@backstage/core-components';
|
|
29
30
|
import { createApp } from '@backstage/app-defaults';
|
|
30
31
|
import { FlatRoutes } from '@backstage/core-app-api';
|
|
32
|
+
import { CatalogGraphPage } from '@backstage/plugin-catalog-graph';
|
|
31
33
|
|
|
32
34
|
const app = createApp({
|
|
33
35
|
apis,
|
|
@@ -37,11 +39,14 @@ const app = createApp({
|
|
|
37
39
|
viewTechDoc: techdocsPlugin.routes.docRoot,
|
|
38
40
|
});
|
|
39
41
|
bind(apiDocsPlugin.externalRoutes, {
|
|
40
|
-
|
|
42
|
+
registerApi: catalogImportPlugin.routes.importPage,
|
|
41
43
|
});
|
|
42
44
|
bind(scaffolderPlugin.externalRoutes, {
|
|
43
45
|
registerComponent: catalogImportPlugin.routes.importPage,
|
|
44
46
|
});
|
|
47
|
+
bind(orgPlugin.externalRoutes, {
|
|
48
|
+
catalogIndex: catalogPlugin.routes.catalogIndex,
|
|
49
|
+
});
|
|
45
50
|
},
|
|
46
51
|
});
|
|
47
52
|
|
|
@@ -76,6 +81,7 @@ const routes = (
|
|
|
76
81
|
{searchPage}
|
|
77
82
|
</Route>
|
|
78
83
|
<Route path="/settings" element={<UserSettingsPage />} />
|
|
84
|
+
<Route path="/catalog-graph" element={<CatalogGraphPage />} />
|
|
79
85
|
</FlatRoutes>
|
|
80
86
|
);
|
|
81
87
|
|
|
@@ -27,7 +27,6 @@ import {
|
|
|
27
27
|
EntityAboutCard,
|
|
28
28
|
EntityDependsOnComponentsCard,
|
|
29
29
|
EntityDependsOnResourcesCard,
|
|
30
|
-
EntitySystemDiagramCard,
|
|
31
30
|
EntityHasComponentsCard,
|
|
32
31
|
EntityHasResourcesCard,
|
|
33
32
|
EntityHasSubcomponentsCard,
|
|
@@ -54,6 +53,20 @@ import {
|
|
|
54
53
|
} from '@backstage/plugin-org';
|
|
55
54
|
import { EntityTechdocsContent } from '@backstage/plugin-techdocs';
|
|
56
55
|
import { EmptyState } from '@backstage/core-components';
|
|
56
|
+
import {
|
|
57
|
+
Direction,
|
|
58
|
+
EntityCatalogGraphCard,
|
|
59
|
+
} from '@backstage/plugin-catalog-graph';
|
|
60
|
+
import {
|
|
61
|
+
RELATION_API_CONSUMED_BY,
|
|
62
|
+
RELATION_API_PROVIDED_BY,
|
|
63
|
+
RELATION_CONSUMES_API,
|
|
64
|
+
RELATION_DEPENDENCY_OF,
|
|
65
|
+
RELATION_DEPENDS_ON,
|
|
66
|
+
RELATION_HAS_PART,
|
|
67
|
+
RELATION_PART_OF,
|
|
68
|
+
RELATION_PROVIDES_API,
|
|
69
|
+
} from '@backstage/catalog-model';
|
|
57
70
|
|
|
58
71
|
const cicdContent = (
|
|
59
72
|
// This is an example of how you can implement your company's logic in entity page.
|
|
@@ -108,6 +121,10 @@ const overviewContent = (
|
|
|
108
121
|
<Grid item md={6}>
|
|
109
122
|
<EntityAboutCard variant="gridItem" />
|
|
110
123
|
</Grid>
|
|
124
|
+
<Grid item md={6} xs={12}>
|
|
125
|
+
<EntityCatalogGraphCard variant="gridItem" height={400} />
|
|
126
|
+
</Grid>
|
|
127
|
+
|
|
111
128
|
<Grid item md={4} xs={12}>
|
|
112
129
|
<EntityLinksCard />
|
|
113
130
|
</Grid>
|
|
@@ -223,6 +240,9 @@ const apiPage = (
|
|
|
223
240
|
<Grid item md={6}>
|
|
224
241
|
<EntityAboutCard />
|
|
225
242
|
</Grid>
|
|
243
|
+
<Grid item md={6} xs={12}>
|
|
244
|
+
<EntityCatalogGraphCard variant="gridItem" height={400} />
|
|
245
|
+
</Grid>
|
|
226
246
|
<Grid item md={4} xs={12}>
|
|
227
247
|
<EntityLinksCard />
|
|
228
248
|
</Grid>
|
|
@@ -290,6 +310,9 @@ const systemPage = (
|
|
|
290
310
|
<Grid item md={6}>
|
|
291
311
|
<EntityAboutCard variant="gridItem" />
|
|
292
312
|
</Grid>
|
|
313
|
+
<Grid item md={6} xs={12}>
|
|
314
|
+
<EntityCatalogGraphCard variant="gridItem" height={400} />
|
|
315
|
+
</Grid>
|
|
293
316
|
<Grid item md={6}>
|
|
294
317
|
<EntityHasComponentsCard variant="gridItem" />
|
|
295
318
|
</Grid>
|
|
@@ -302,7 +325,23 @@ const systemPage = (
|
|
|
302
325
|
</Grid>
|
|
303
326
|
</EntityLayout.Route>
|
|
304
327
|
<EntityLayout.Route path="/diagram" title="Diagram">
|
|
305
|
-
<
|
|
328
|
+
<EntityCatalogGraphCard
|
|
329
|
+
variant="gridItem"
|
|
330
|
+
direction={Direction.TOP_BOTTOM}
|
|
331
|
+
title="System Diagram"
|
|
332
|
+
height={700}
|
|
333
|
+
relations={[
|
|
334
|
+
RELATION_PART_OF,
|
|
335
|
+
RELATION_HAS_PART,
|
|
336
|
+
RELATION_API_CONSUMED_BY,
|
|
337
|
+
RELATION_API_PROVIDED_BY,
|
|
338
|
+
RELATION_CONSUMES_API,
|
|
339
|
+
RELATION_PROVIDES_API,
|
|
340
|
+
RELATION_DEPENDENCY_OF,
|
|
341
|
+
RELATION_DEPENDS_ON,
|
|
342
|
+
]}
|
|
343
|
+
unidirectional={false}
|
|
344
|
+
/>
|
|
306
345
|
</EntityLayout.Route>
|
|
307
346
|
</EntityLayout>
|
|
308
347
|
);
|
|
@@ -315,6 +354,9 @@ const domainPage = (
|
|
|
315
354
|
<Grid item md={6}>
|
|
316
355
|
<EntityAboutCard variant="gridItem" />
|
|
317
356
|
</Grid>
|
|
357
|
+
<Grid item md={6} xs={12}>
|
|
358
|
+
<EntityCatalogGraphCard variant="gridItem" height={400} />
|
|
359
|
+
</Grid>
|
|
318
360
|
<Grid item md={6}>
|
|
319
361
|
<EntityHasSystemsCard variant="gridItem" />
|
|
320
362
|
</Grid>
|
|
@@ -2,6 +2,10 @@ import React from 'react';
|
|
|
2
2
|
import { makeStyles, Theme, Grid, List, Paper } from '@material-ui/core';
|
|
3
3
|
|
|
4
4
|
import { CatalogResultListItem } from '@backstage/plugin-catalog';
|
|
5
|
+
import {
|
|
6
|
+
catalogApiRef,
|
|
7
|
+
CATALOG_FILTER_EXISTS,
|
|
8
|
+
} from '@backstage/plugin-catalog-react';
|
|
5
9
|
import { DocsResultListItem } from '@backstage/plugin-techdocs';
|
|
6
10
|
|
|
7
11
|
import {
|
|
@@ -10,6 +14,7 @@ import {
|
|
|
10
14
|
SearchResult,
|
|
11
15
|
SearchType,
|
|
12
16
|
DefaultResultListItem,
|
|
17
|
+
useSearch,
|
|
13
18
|
} from '@backstage/plugin-search';
|
|
14
19
|
import {
|
|
15
20
|
CatalogIcon,
|
|
@@ -18,6 +23,7 @@ import {
|
|
|
18
23
|
Header,
|
|
19
24
|
Page,
|
|
20
25
|
} from '@backstage/core-components';
|
|
26
|
+
import { useApi } from '@backstage/core-plugin-api';
|
|
21
27
|
|
|
22
28
|
const useStyles = makeStyles((theme: Theme) => ({
|
|
23
29
|
bar: {
|
|
@@ -36,6 +42,8 @@ const useStyles = makeStyles((theme: Theme) => ({
|
|
|
36
42
|
|
|
37
43
|
const SearchPage = () => {
|
|
38
44
|
const classes = useStyles();
|
|
45
|
+
const { types } = useSearch();
|
|
46
|
+
const catalogApi = useApi(catalogApiRef);
|
|
39
47
|
|
|
40
48
|
return (
|
|
41
49
|
<Page themeId="home">
|
|
@@ -65,13 +73,36 @@ const SearchPage = () => {
|
|
|
65
73
|
]}
|
|
66
74
|
/>
|
|
67
75
|
<Paper className={classes.filters}>
|
|
76
|
+
{types.includes('techdocs') && (
|
|
77
|
+
<SearchFilter.Select
|
|
78
|
+
className={classes.filter}
|
|
79
|
+
label="Entity"
|
|
80
|
+
name="name"
|
|
81
|
+
values={async () => {
|
|
82
|
+
// Return a list of entities which are documented.
|
|
83
|
+
const { items } = await catalogApi.getEntities({
|
|
84
|
+
fields: ['metadata.name'],
|
|
85
|
+
filter: {
|
|
86
|
+
'metadata.annotations.backstage.io/techdocs-ref':
|
|
87
|
+
CATALOG_FILTER_EXISTS,
|
|
88
|
+
},
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
const names = items.map(entity => entity.metadata.name);
|
|
92
|
+
names.sort();
|
|
93
|
+
return names;
|
|
94
|
+
}}
|
|
95
|
+
/>
|
|
96
|
+
)}
|
|
68
97
|
<SearchFilter.Select
|
|
69
98
|
className={classes.filter}
|
|
99
|
+
label="Kind"
|
|
70
100
|
name="kind"
|
|
71
101
|
values={['Component', 'Template']}
|
|
72
102
|
/>
|
|
73
103
|
<SearchFilter.Checkbox
|
|
74
104
|
className={classes.filter}
|
|
105
|
+
label="Lifecycle"
|
|
75
106
|
name="lifecycle"
|
|
76
107
|
values={['experimental', 'production']}
|
|
77
108
|
/>
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"migrate:create": "knex migrate:make -x ts"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"app": "
|
|
17
|
+
"app": "file:../app",
|
|
18
18
|
"@backstage/backend-common": "^{{version '@backstage/backend-common'}}",
|
|
19
19
|
"@backstage/backend-tasks": "^{{version '@backstage/backend-tasks'}}",
|
|
20
20
|
"@backstage/catalog-model": "^{{version '@backstage/catalog-model'}}",
|
|
@@ -7,6 +7,13 @@ export default async function createPlugin({
|
|
|
7
7
|
database,
|
|
8
8
|
config,
|
|
9
9
|
discovery,
|
|
10
|
+
tokenManager,
|
|
10
11
|
}: PluginEnvironment): Promise<Router> {
|
|
11
|
-
return await createRouter({
|
|
12
|
+
return await createRouter({
|
|
13
|
+
logger,
|
|
14
|
+
config,
|
|
15
|
+
database,
|
|
16
|
+
discovery,
|
|
17
|
+
tokenManager,
|
|
18
|
+
});
|
|
12
19
|
}
|
|
@@ -10,6 +10,7 @@ import { DefaultTechDocsCollator } from '@backstage/plugin-techdocs-backend';
|
|
|
10
10
|
|
|
11
11
|
export default async function createPlugin({
|
|
12
12
|
logger,
|
|
13
|
+
permissions,
|
|
13
14
|
discovery,
|
|
14
15
|
config,
|
|
15
16
|
tokenManager,
|
|
@@ -49,6 +50,9 @@ export default async function createPlugin({
|
|
|
49
50
|
|
|
50
51
|
return await createRouter({
|
|
51
52
|
engine: indexBuilder.getSearchEngine(),
|
|
53
|
+
types: indexBuilder.getDocumentTypes(),
|
|
54
|
+
permissions,
|
|
55
|
+
config,
|
|
52
56
|
logger,
|
|
53
57
|
});
|
|
54
58
|
}
|