From bc69315b5a64d2b5114cc54614f35f789ea32f41 Mon Sep 17 00:00:00 2001 From: Emma Indal Date: Mon, 22 Jun 2020 14:21:15 +0200 Subject: [PATCH 01/14] feat(techdocs): cli skeleton --- .github/CODEOWNERS | 5 +- packages/app/package.json | 1 + packages/app/src/plugins.ts | 1 + plugins/techdocs-cli/.eslintrc.js | 3 + plugins/techdocs-cli/README.md | 13 +++ plugins/techdocs-cli/dev/index.tsx | 20 ++++ plugins/techdocs-cli/package.json | 47 ++++++++ .../ExampleComponent.test.tsx | 34 ++++++ .../ExampleComponent/ExampleComponent.tsx | 57 +++++++++ .../src/components/ExampleComponent/index.ts | 17 +++ .../ExampleFetchComponent.test.tsx | 28 +++++ .../ExampleFetchComponent.tsx | 108 ++++++++++++++++++ .../components/ExampleFetchComponent/index.ts | 17 +++ plugins/techdocs-cli/src/index.ts | 17 +++ plugins/techdocs-cli/src/plugin.test.ts | 23 ++++ plugins/techdocs-cli/src/plugin.ts | 45 ++++++++ plugins/techdocs-cli/src/setupTests.ts | 18 +++ 17 files changed, 452 insertions(+), 2 deletions(-) create mode 100644 plugins/techdocs-cli/.eslintrc.js create mode 100644 plugins/techdocs-cli/README.md create mode 100644 plugins/techdocs-cli/dev/index.tsx create mode 100644 plugins/techdocs-cli/package.json create mode 100644 plugins/techdocs-cli/src/components/ExampleComponent/ExampleComponent.test.tsx create mode 100644 plugins/techdocs-cli/src/components/ExampleComponent/ExampleComponent.tsx create mode 100644 plugins/techdocs-cli/src/components/ExampleComponent/index.ts create mode 100644 plugins/techdocs-cli/src/components/ExampleFetchComponent/ExampleFetchComponent.test.tsx create mode 100644 plugins/techdocs-cli/src/components/ExampleFetchComponent/ExampleFetchComponent.tsx create mode 100644 plugins/techdocs-cli/src/components/ExampleFetchComponent/index.ts create mode 100644 plugins/techdocs-cli/src/index.ts create mode 100644 plugins/techdocs-cli/src/plugin.test.ts create mode 100644 plugins/techdocs-cli/src/plugin.ts create mode 100644 plugins/techdocs-cli/src/setupTests.ts diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index fbb99eec31..f956ca4dca 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -4,5 +4,6 @@ # The last matching pattern takes precedence. # https://help.github.com/articles/about-codeowners/ -* @spotify/backstage-core -/plugins/techdocs @spotify/techdocs-core +* @spotify/backstage-core +/plugins/techdocs @spotify/techdocs-core +/plugins/techdocs-cli @spotify/techdocs-core diff --git a/packages/app/package.json b/packages/app/package.json index 6b872156d6..ad2a8988b2 100644 --- a/packages/app/package.json +++ b/packages/app/package.json @@ -15,6 +15,7 @@ "@backstage/plugin-sentry": "^0.1.1-alpha.9", "@backstage/plugin-tech-radar": "^0.1.1-alpha.9", "@backstage/plugin-techdocs": "^0.1.1-alpha.9", + "@backstage/plugin-techdocs-cli": "^0.1.1-alpha.9", "@backstage/plugin-welcome": "^0.1.1-alpha.9", "@backstage/test-utils": "^0.1.1-alpha.9", "@backstage/theme": "^0.1.1-alpha.9", diff --git a/packages/app/src/plugins.ts b/packages/app/src/plugins.ts index 05373d7d96..93935a92b9 100644 --- a/packages/app/src/plugins.ts +++ b/packages/app/src/plugins.ts @@ -24,3 +24,4 @@ export { plugin as RegisterComponent } from '@backstage/plugin-register-componen export { plugin as Sentry } from '@backstage/plugin-sentry'; export { plugin as GitopsProfiles } from '@backstage/plugin-gitops-profiles'; export { plugin as TechDocs } from '@backstage/plugin-techdocs'; +export { plugin as TechdocsCli } from '@backstage/plugin-techdocs-cli'; diff --git a/plugins/techdocs-cli/.eslintrc.js b/plugins/techdocs-cli/.eslintrc.js new file mode 100644 index 0000000000..13573efa9c --- /dev/null +++ b/plugins/techdocs-cli/.eslintrc.js @@ -0,0 +1,3 @@ +module.exports = { + extends: [require.resolve('@backstage/cli/config/eslint')], +}; diff --git a/plugins/techdocs-cli/README.md b/plugins/techdocs-cli/README.md new file mode 100644 index 0000000000..f4b9534bfa --- /dev/null +++ b/plugins/techdocs-cli/README.md @@ -0,0 +1,13 @@ +# techdocs-cli + +Welcome to the techdocs-cli plugin! + +_This plugin was created through the Backstage CLI_ + +## Getting started + +Your plugin has been added to the example app in this repository, meaning you'll be able to access it by running `yarn start` in the root directory, and then navigating to [/techdocs-cli](http://localhost:3000/techdocs-cli). + +You can also serve the plugin in isolation by running `yarn start` in the plugin directory. +This method of serving the plugin provides quicker iteration speed and a faster startup and hot reloads. +It is only meant for local development, and the setup for it can be found inside the [/dev](/dev) directory. diff --git a/plugins/techdocs-cli/dev/index.tsx b/plugins/techdocs-cli/dev/index.tsx new file mode 100644 index 0000000000..812a5585d4 --- /dev/null +++ b/plugins/techdocs-cli/dev/index.tsx @@ -0,0 +1,20 @@ +/* + * Copyright 2020 Spotify AB + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { createDevApp } from '@backstage/dev-utils'; +import { plugin } from '../src/plugin'; + +createDevApp().registerPlugin(plugin).render(); diff --git a/plugins/techdocs-cli/package.json b/plugins/techdocs-cli/package.json new file mode 100644 index 0000000000..e4f9b198e0 --- /dev/null +++ b/plugins/techdocs-cli/package.json @@ -0,0 +1,47 @@ +{ + "name": "@backstage/plugin-techdocs-cli", + "version": "0.1.1-alpha.9", + "main": "src/index.ts", + "types": "src/index.ts", + "license": "Apache-2.0", + "private": true, + "publishConfig": { + "access": "public", + "main": "dist/index.esm.js", + "types": "dist/index.d.ts" + }, + "scripts": { + "build": "backstage-cli plugin:build", + "start": "backstage-cli plugin:serve", + "lint": "backstage-cli lint", + "test": "backstage-cli test", + "diff": "backstage-cli plugin:diff", + "prepack": "backstage-cli prepack", + "postpack": "backstage-cli postpack", + "clean": "backstage-cli clean" + }, + "dependencies": { + "@backstage/core": "^0.1.1-alpha.9", + "@backstage/theme": "^0.1.1-alpha.9", + "@material-ui/core": "^4.9.1", + "@material-ui/icons": "^4.9.1", + "@material-ui/lab": "4.0.0-alpha.45", + "react": "^16.13.1", + "react-dom": "^16.13.1", + "react-use": "^14.2.0" + }, + "devDependencies": { + "@backstage/cli": "^0.1.1-alpha.9", + "@backstage/dev-utils": "^0.1.1-alpha.9", + "@testing-library/jest-dom": "^5.7.0", + "@testing-library/react": "^9.3.2", + "@testing-library/user-event": "^10.2.4", + "@types/jest": "^25.2.2", + "@types/node": "^12.0.0", + "@types/testing-library__jest-dom": "^5.0.4", + "jest-fetch-mock": "^3.0.3" + }, + "files": [ + "dist/**/*.{js,d.ts}" + ] +} diff --git a/plugins/techdocs-cli/src/components/ExampleComponent/ExampleComponent.test.tsx b/plugins/techdocs-cli/src/components/ExampleComponent/ExampleComponent.test.tsx new file mode 100644 index 0000000000..8a565efcff --- /dev/null +++ b/plugins/techdocs-cli/src/components/ExampleComponent/ExampleComponent.test.tsx @@ -0,0 +1,34 @@ +/* + * Copyright 2020 Spotify AB + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import React from 'react'; +import { render } from '@testing-library/react'; +import mockFetch from 'jest-fetch-mock'; +import ExampleComponent from './ExampleComponent'; +import { ThemeProvider } from '@material-ui/core'; +import { lightTheme } from '@backstage/theme'; + +describe('ExampleComponent', () => { + it('should render', () => { + mockFetch.mockResponse(() => new Promise(() => {})); + const rendered = render( + + + , + ); + expect(rendered.getByText('Welcome to techdocs-cli!')).toBeInTheDocument(); + }); +}); diff --git a/plugins/techdocs-cli/src/components/ExampleComponent/ExampleComponent.tsx b/plugins/techdocs-cli/src/components/ExampleComponent/ExampleComponent.tsx new file mode 100644 index 0000000000..7aca7453d6 --- /dev/null +++ b/plugins/techdocs-cli/src/components/ExampleComponent/ExampleComponent.tsx @@ -0,0 +1,57 @@ +/* + * Copyright 2020 Spotify AB + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import React, { FC } from 'react'; +import { Typography, Grid } from '@material-ui/core'; +import { + InfoCard, + Header, + Page, + pageTheme, + Content, + ContentHeader, + HeaderLabel, + SupportButton, +} from '@backstage/core'; +import ExampleFetchComponent from '../ExampleFetchComponent'; + +const ExampleComponent: FC<{}> = () => ( + +
+ + +
+ + + A description of your plugin goes here. + + + + + + All content should be wrapped in a card like this. + + + + + + + + +
+); + +export default ExampleComponent; diff --git a/plugins/techdocs-cli/src/components/ExampleComponent/index.ts b/plugins/techdocs-cli/src/components/ExampleComponent/index.ts new file mode 100644 index 0000000000..e785d45082 --- /dev/null +++ b/plugins/techdocs-cli/src/components/ExampleComponent/index.ts @@ -0,0 +1,17 @@ +/* + * Copyright 2020 Spotify AB + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export { default } from './ExampleComponent'; diff --git a/plugins/techdocs-cli/src/components/ExampleFetchComponent/ExampleFetchComponent.test.tsx b/plugins/techdocs-cli/src/components/ExampleFetchComponent/ExampleFetchComponent.test.tsx new file mode 100644 index 0000000000..7fecdc6f11 --- /dev/null +++ b/plugins/techdocs-cli/src/components/ExampleFetchComponent/ExampleFetchComponent.test.tsx @@ -0,0 +1,28 @@ +/* + * Copyright 2020 Spotify AB + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import React from 'react'; +import { render } from '@testing-library/react'; +import mockFetch from 'jest-fetch-mock'; +import ExampleFetchComponent from './ExampleFetchComponent'; + +describe('ExampleFetchComponent', () => { + it('should render', async () => { + mockFetch.mockResponse(() => new Promise(() => {})); + const rendered = render(); + expect(await rendered.findByTestId('progress')).toBeInTheDocument(); + }); +}); diff --git a/plugins/techdocs-cli/src/components/ExampleFetchComponent/ExampleFetchComponent.tsx b/plugins/techdocs-cli/src/components/ExampleFetchComponent/ExampleFetchComponent.tsx new file mode 100644 index 0000000000..c2139befec --- /dev/null +++ b/plugins/techdocs-cli/src/components/ExampleFetchComponent/ExampleFetchComponent.tsx @@ -0,0 +1,108 @@ +/* + * Copyright 2020 Spotify AB + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import React, { FC } from 'react'; +import { makeStyles } from '@material-ui/core/styles'; +import { Table, TableColumn, Progress } from '@backstage/core'; +import Alert from '@material-ui/lab/Alert'; +import { useAsync } from 'react-use'; + +const useStyles = makeStyles({ + avatar: { + height: 32, + width: 32, + borderRadius: '50%', + }, +}); + +type User = { + gender: string; // "male" + name: { + title: string; // "Mr", + first: string; // "Duane", + last: string; // "Reed" + }; + location: object; // {street: {number: 5060, name: "Hickory Creek Dr"}, city: "Albany", state: "New South Wales",…} + email: string; // "duane.reed@example.com" + login: object; // {uuid: "4b785022-9a23-4ab9-8a23-cb3fb43969a9", username: "blackdog796", password: "patch",…} + dob: object; // {date: "1983-06-22T12:30:23.016Z", age: 37} + registered: object; // {date: "2006-06-13T18:48:28.037Z", age: 14} + phone: string; // "07-2154-5651" + cell: string; // "0405-592-879" + id: { + name: string; // "TFN", + value: string; // "796260432" + }; + picture: { medium: string }; // {medium: "https://randomuser.me/api/portraits/men/95.jpg",…} + nat: string; // "AU" +}; + +type DenseTableProps = { + users: User[]; +}; + +export const DenseTable: FC = ({ users }) => { + const classes = useStyles(); + + const columns: TableColumn[] = [ + { title: 'Avatar', field: 'avatar' }, + { title: 'Name', field: 'name' }, + { title: 'Email', field: 'email' }, + { title: 'Nationality', field: 'nationality' }, + ]; + + const data = users.map(user => { + return { + avatar: ( + {user.name.first} + ), + name: `${user.name.first} ${user.name.last}`, + email: user.email, + nationality: user.nat, + }; + }); + + return ( + + ); +}; + +const ExampleFetchComponent: FC<{}> = () => { + const { value, loading, error } = useAsync(async (): Promise => { + const response = await fetch('https://randomuser.me/api/?results=20'); + const data = await response.json(); + return data.results; + }, []); + + if (loading) { + return ; + } else if (error) { + return {error.message}; + } + + return ; +}; + +export default ExampleFetchComponent; diff --git a/plugins/techdocs-cli/src/components/ExampleFetchComponent/index.ts b/plugins/techdocs-cli/src/components/ExampleFetchComponent/index.ts new file mode 100644 index 0000000000..28482f9fe1 --- /dev/null +++ b/plugins/techdocs-cli/src/components/ExampleFetchComponent/index.ts @@ -0,0 +1,17 @@ +/* + * Copyright 2020 Spotify AB + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export { default } from './ExampleFetchComponent'; diff --git a/plugins/techdocs-cli/src/index.ts b/plugins/techdocs-cli/src/index.ts new file mode 100644 index 0000000000..3a0a0fe2d3 --- /dev/null +++ b/plugins/techdocs-cli/src/index.ts @@ -0,0 +1,17 @@ +/* + * Copyright 2020 Spotify AB + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export { plugin } from './plugin'; diff --git a/plugins/techdocs-cli/src/plugin.test.ts b/plugins/techdocs-cli/src/plugin.test.ts new file mode 100644 index 0000000000..6f385bbe53 --- /dev/null +++ b/plugins/techdocs-cli/src/plugin.test.ts @@ -0,0 +1,23 @@ +/* + * Copyright 2020 Spotify AB + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { plugin } from './plugin'; + +describe('techdocs-cli', () => { + it('should export plugin', () => { + expect(plugin).toBeDefined(); + }); +}); diff --git a/plugins/techdocs-cli/src/plugin.ts b/plugins/techdocs-cli/src/plugin.ts new file mode 100644 index 0000000000..fcba712d9f --- /dev/null +++ b/plugins/techdocs-cli/src/plugin.ts @@ -0,0 +1,45 @@ +/* + * Copyright 2020 Spotify AB + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* + * Copyright 2020 Spotify AB + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { createPlugin, createRouteRef } from '@backstage/core'; +import ExampleComponent from './components/ExampleComponent'; + +export const rootRouteRef = createRouteRef({ + path: '/techdocs-cli', + title: 'techdocs-cli', +}); + +export const plugin = createPlugin({ + id: 'techdocs-cli', + register({ router }) { + router.addRoute(rootRouteRef, ExampleComponent); + }, +}); diff --git a/plugins/techdocs-cli/src/setupTests.ts b/plugins/techdocs-cli/src/setupTests.ts new file mode 100644 index 0000000000..e34bc46f4b --- /dev/null +++ b/plugins/techdocs-cli/src/setupTests.ts @@ -0,0 +1,18 @@ +/* + * Copyright 2020 Spotify AB + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import '@testing-library/jest-dom'; +require('jest-fetch-mock').enableMocks(); From 4a6e3355aabdfca80fbc38ddc98adcb2431a051d Mon Sep 17 00:00:00 2001 From: Emma Indal Date: Mon, 22 Jun 2020 14:30:15 +0200 Subject: [PATCH 02/14] fix(app): remove techdocs cli --- packages/app/package.json | 1 - packages/app/src/plugins.ts | 1 - 2 files changed, 2 deletions(-) diff --git a/packages/app/package.json b/packages/app/package.json index ad2a8988b2..6b872156d6 100644 --- a/packages/app/package.json +++ b/packages/app/package.json @@ -15,7 +15,6 @@ "@backstage/plugin-sentry": "^0.1.1-alpha.9", "@backstage/plugin-tech-radar": "^0.1.1-alpha.9", "@backstage/plugin-techdocs": "^0.1.1-alpha.9", - "@backstage/plugin-techdocs-cli": "^0.1.1-alpha.9", "@backstage/plugin-welcome": "^0.1.1-alpha.9", "@backstage/test-utils": "^0.1.1-alpha.9", "@backstage/theme": "^0.1.1-alpha.9", diff --git a/packages/app/src/plugins.ts b/packages/app/src/plugins.ts index 93935a92b9..05373d7d96 100644 --- a/packages/app/src/plugins.ts +++ b/packages/app/src/plugins.ts @@ -24,4 +24,3 @@ export { plugin as RegisterComponent } from '@backstage/plugin-register-componen export { plugin as Sentry } from '@backstage/plugin-sentry'; export { plugin as GitopsProfiles } from '@backstage/plugin-gitops-profiles'; export { plugin as TechDocs } from '@backstage/plugin-techdocs'; -export { plugin as TechdocsCli } from '@backstage/plugin-techdocs-cli'; From 3b16d4eaaf452d134a5883385da8f6185d6e187c Mon Sep 17 00:00:00 2001 From: Emma Indal Date: Mon, 22 Jun 2020 14:37:47 +0200 Subject: [PATCH 03/14] fix(techdocs-cli): move from plugins to packages --- {plugins => packages/techdocs-cli}/techdocs-cli/.eslintrc.js | 0 {plugins => packages/techdocs-cli}/techdocs-cli/README.md | 0 {plugins => packages/techdocs-cli}/techdocs-cli/dev/index.tsx | 0 {plugins => packages/techdocs-cli}/techdocs-cli/package.json | 0 .../src/components/ExampleComponent/ExampleComponent.test.tsx | 0 .../src/components/ExampleComponent/ExampleComponent.tsx | 0 .../techdocs-cli/src/components/ExampleComponent/index.ts | 0 .../ExampleFetchComponent/ExampleFetchComponent.test.tsx | 0 .../components/ExampleFetchComponent/ExampleFetchComponent.tsx | 0 .../techdocs-cli/src/components/ExampleFetchComponent/index.ts | 0 {plugins => packages/techdocs-cli}/techdocs-cli/src/index.ts | 0 .../techdocs-cli}/techdocs-cli/src/plugin.test.ts | 0 {plugins => packages/techdocs-cli}/techdocs-cli/src/plugin.ts | 0 {plugins => packages/techdocs-cli}/techdocs-cli/src/setupTests.ts | 0 14 files changed, 0 insertions(+), 0 deletions(-) rename {plugins => packages/techdocs-cli}/techdocs-cli/.eslintrc.js (100%) rename {plugins => packages/techdocs-cli}/techdocs-cli/README.md (100%) rename {plugins => packages/techdocs-cli}/techdocs-cli/dev/index.tsx (100%) rename {plugins => packages/techdocs-cli}/techdocs-cli/package.json (100%) rename {plugins => packages/techdocs-cli}/techdocs-cli/src/components/ExampleComponent/ExampleComponent.test.tsx (100%) rename {plugins => packages/techdocs-cli}/techdocs-cli/src/components/ExampleComponent/ExampleComponent.tsx (100%) rename {plugins => packages/techdocs-cli}/techdocs-cli/src/components/ExampleComponent/index.ts (100%) rename {plugins => packages/techdocs-cli}/techdocs-cli/src/components/ExampleFetchComponent/ExampleFetchComponent.test.tsx (100%) rename {plugins => packages/techdocs-cli}/techdocs-cli/src/components/ExampleFetchComponent/ExampleFetchComponent.tsx (100%) rename {plugins => packages/techdocs-cli}/techdocs-cli/src/components/ExampleFetchComponent/index.ts (100%) rename {plugins => packages/techdocs-cli}/techdocs-cli/src/index.ts (100%) rename {plugins => packages/techdocs-cli}/techdocs-cli/src/plugin.test.ts (100%) rename {plugins => packages/techdocs-cli}/techdocs-cli/src/plugin.ts (100%) rename {plugins => packages/techdocs-cli}/techdocs-cli/src/setupTests.ts (100%) diff --git a/plugins/techdocs-cli/.eslintrc.js b/packages/techdocs-cli/techdocs-cli/.eslintrc.js similarity index 100% rename from plugins/techdocs-cli/.eslintrc.js rename to packages/techdocs-cli/techdocs-cli/.eslintrc.js diff --git a/plugins/techdocs-cli/README.md b/packages/techdocs-cli/techdocs-cli/README.md similarity index 100% rename from plugins/techdocs-cli/README.md rename to packages/techdocs-cli/techdocs-cli/README.md diff --git a/plugins/techdocs-cli/dev/index.tsx b/packages/techdocs-cli/techdocs-cli/dev/index.tsx similarity index 100% rename from plugins/techdocs-cli/dev/index.tsx rename to packages/techdocs-cli/techdocs-cli/dev/index.tsx diff --git a/plugins/techdocs-cli/package.json b/packages/techdocs-cli/techdocs-cli/package.json similarity index 100% rename from plugins/techdocs-cli/package.json rename to packages/techdocs-cli/techdocs-cli/package.json diff --git a/plugins/techdocs-cli/src/components/ExampleComponent/ExampleComponent.test.tsx b/packages/techdocs-cli/techdocs-cli/src/components/ExampleComponent/ExampleComponent.test.tsx similarity index 100% rename from plugins/techdocs-cli/src/components/ExampleComponent/ExampleComponent.test.tsx rename to packages/techdocs-cli/techdocs-cli/src/components/ExampleComponent/ExampleComponent.test.tsx diff --git a/plugins/techdocs-cli/src/components/ExampleComponent/ExampleComponent.tsx b/packages/techdocs-cli/techdocs-cli/src/components/ExampleComponent/ExampleComponent.tsx similarity index 100% rename from plugins/techdocs-cli/src/components/ExampleComponent/ExampleComponent.tsx rename to packages/techdocs-cli/techdocs-cli/src/components/ExampleComponent/ExampleComponent.tsx diff --git a/plugins/techdocs-cli/src/components/ExampleComponent/index.ts b/packages/techdocs-cli/techdocs-cli/src/components/ExampleComponent/index.ts similarity index 100% rename from plugins/techdocs-cli/src/components/ExampleComponent/index.ts rename to packages/techdocs-cli/techdocs-cli/src/components/ExampleComponent/index.ts diff --git a/plugins/techdocs-cli/src/components/ExampleFetchComponent/ExampleFetchComponent.test.tsx b/packages/techdocs-cli/techdocs-cli/src/components/ExampleFetchComponent/ExampleFetchComponent.test.tsx similarity index 100% rename from plugins/techdocs-cli/src/components/ExampleFetchComponent/ExampleFetchComponent.test.tsx rename to packages/techdocs-cli/techdocs-cli/src/components/ExampleFetchComponent/ExampleFetchComponent.test.tsx diff --git a/plugins/techdocs-cli/src/components/ExampleFetchComponent/ExampleFetchComponent.tsx b/packages/techdocs-cli/techdocs-cli/src/components/ExampleFetchComponent/ExampleFetchComponent.tsx similarity index 100% rename from plugins/techdocs-cli/src/components/ExampleFetchComponent/ExampleFetchComponent.tsx rename to packages/techdocs-cli/techdocs-cli/src/components/ExampleFetchComponent/ExampleFetchComponent.tsx diff --git a/plugins/techdocs-cli/src/components/ExampleFetchComponent/index.ts b/packages/techdocs-cli/techdocs-cli/src/components/ExampleFetchComponent/index.ts similarity index 100% rename from plugins/techdocs-cli/src/components/ExampleFetchComponent/index.ts rename to packages/techdocs-cli/techdocs-cli/src/components/ExampleFetchComponent/index.ts diff --git a/plugins/techdocs-cli/src/index.ts b/packages/techdocs-cli/techdocs-cli/src/index.ts similarity index 100% rename from plugins/techdocs-cli/src/index.ts rename to packages/techdocs-cli/techdocs-cli/src/index.ts diff --git a/plugins/techdocs-cli/src/plugin.test.ts b/packages/techdocs-cli/techdocs-cli/src/plugin.test.ts similarity index 100% rename from plugins/techdocs-cli/src/plugin.test.ts rename to packages/techdocs-cli/techdocs-cli/src/plugin.test.ts diff --git a/plugins/techdocs-cli/src/plugin.ts b/packages/techdocs-cli/techdocs-cli/src/plugin.ts similarity index 100% rename from plugins/techdocs-cli/src/plugin.ts rename to packages/techdocs-cli/techdocs-cli/src/plugin.ts diff --git a/plugins/techdocs-cli/src/setupTests.ts b/packages/techdocs-cli/techdocs-cli/src/setupTests.ts similarity index 100% rename from plugins/techdocs-cli/src/setupTests.ts rename to packages/techdocs-cli/techdocs-cli/src/setupTests.ts From e2c52bafc8be069e3d4d1b3d68f196d6f4acb739 Mon Sep 17 00:00:00 2001 From: Emma Indal Date: Mon, 22 Jun 2020 14:39:18 +0200 Subject: [PATCH 04/14] fix(codeowners): change techdocs-cli to packages --- .github/CODEOWNERS | 2 +- packages/techdocs-cli/{techdocs-cli => }/.eslintrc.js | 0 packages/techdocs-cli/{techdocs-cli => }/README.md | 0 packages/techdocs-cli/{techdocs-cli => }/dev/index.tsx | 0 packages/techdocs-cli/{techdocs-cli => }/package.json | 0 .../src/components/ExampleComponent/ExampleComponent.test.tsx | 0 .../src/components/ExampleComponent/ExampleComponent.tsx | 0 .../{techdocs-cli => }/src/components/ExampleComponent/index.ts | 0 .../ExampleFetchComponent/ExampleFetchComponent.test.tsx | 0 .../components/ExampleFetchComponent/ExampleFetchComponent.tsx | 0 .../src/components/ExampleFetchComponent/index.ts | 0 packages/techdocs-cli/{techdocs-cli => }/src/index.ts | 0 packages/techdocs-cli/{techdocs-cli => }/src/plugin.test.ts | 0 packages/techdocs-cli/{techdocs-cli => }/src/plugin.ts | 0 packages/techdocs-cli/{techdocs-cli => }/src/setupTests.ts | 0 15 files changed, 1 insertion(+), 1 deletion(-) rename packages/techdocs-cli/{techdocs-cli => }/.eslintrc.js (100%) rename packages/techdocs-cli/{techdocs-cli => }/README.md (100%) rename packages/techdocs-cli/{techdocs-cli => }/dev/index.tsx (100%) rename packages/techdocs-cli/{techdocs-cli => }/package.json (100%) rename packages/techdocs-cli/{techdocs-cli => }/src/components/ExampleComponent/ExampleComponent.test.tsx (100%) rename packages/techdocs-cli/{techdocs-cli => }/src/components/ExampleComponent/ExampleComponent.tsx (100%) rename packages/techdocs-cli/{techdocs-cli => }/src/components/ExampleComponent/index.ts (100%) rename packages/techdocs-cli/{techdocs-cli => }/src/components/ExampleFetchComponent/ExampleFetchComponent.test.tsx (100%) rename packages/techdocs-cli/{techdocs-cli => }/src/components/ExampleFetchComponent/ExampleFetchComponent.tsx (100%) rename packages/techdocs-cli/{techdocs-cli => }/src/components/ExampleFetchComponent/index.ts (100%) rename packages/techdocs-cli/{techdocs-cli => }/src/index.ts (100%) rename packages/techdocs-cli/{techdocs-cli => }/src/plugin.test.ts (100%) rename packages/techdocs-cli/{techdocs-cli => }/src/plugin.ts (100%) rename packages/techdocs-cli/{techdocs-cli => }/src/setupTests.ts (100%) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index f956ca4dca..751ec4914d 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -6,4 +6,4 @@ * @spotify/backstage-core /plugins/techdocs @spotify/techdocs-core -/plugins/techdocs-cli @spotify/techdocs-core +/packages/techdocs-cli @spotify/techdocs-core diff --git a/packages/techdocs-cli/techdocs-cli/.eslintrc.js b/packages/techdocs-cli/.eslintrc.js similarity index 100% rename from packages/techdocs-cli/techdocs-cli/.eslintrc.js rename to packages/techdocs-cli/.eslintrc.js diff --git a/packages/techdocs-cli/techdocs-cli/README.md b/packages/techdocs-cli/README.md similarity index 100% rename from packages/techdocs-cli/techdocs-cli/README.md rename to packages/techdocs-cli/README.md diff --git a/packages/techdocs-cli/techdocs-cli/dev/index.tsx b/packages/techdocs-cli/dev/index.tsx similarity index 100% rename from packages/techdocs-cli/techdocs-cli/dev/index.tsx rename to packages/techdocs-cli/dev/index.tsx diff --git a/packages/techdocs-cli/techdocs-cli/package.json b/packages/techdocs-cli/package.json similarity index 100% rename from packages/techdocs-cli/techdocs-cli/package.json rename to packages/techdocs-cli/package.json diff --git a/packages/techdocs-cli/techdocs-cli/src/components/ExampleComponent/ExampleComponent.test.tsx b/packages/techdocs-cli/src/components/ExampleComponent/ExampleComponent.test.tsx similarity index 100% rename from packages/techdocs-cli/techdocs-cli/src/components/ExampleComponent/ExampleComponent.test.tsx rename to packages/techdocs-cli/src/components/ExampleComponent/ExampleComponent.test.tsx diff --git a/packages/techdocs-cli/techdocs-cli/src/components/ExampleComponent/ExampleComponent.tsx b/packages/techdocs-cli/src/components/ExampleComponent/ExampleComponent.tsx similarity index 100% rename from packages/techdocs-cli/techdocs-cli/src/components/ExampleComponent/ExampleComponent.tsx rename to packages/techdocs-cli/src/components/ExampleComponent/ExampleComponent.tsx diff --git a/packages/techdocs-cli/techdocs-cli/src/components/ExampleComponent/index.ts b/packages/techdocs-cli/src/components/ExampleComponent/index.ts similarity index 100% rename from packages/techdocs-cli/techdocs-cli/src/components/ExampleComponent/index.ts rename to packages/techdocs-cli/src/components/ExampleComponent/index.ts diff --git a/packages/techdocs-cli/techdocs-cli/src/components/ExampleFetchComponent/ExampleFetchComponent.test.tsx b/packages/techdocs-cli/src/components/ExampleFetchComponent/ExampleFetchComponent.test.tsx similarity index 100% rename from packages/techdocs-cli/techdocs-cli/src/components/ExampleFetchComponent/ExampleFetchComponent.test.tsx rename to packages/techdocs-cli/src/components/ExampleFetchComponent/ExampleFetchComponent.test.tsx diff --git a/packages/techdocs-cli/techdocs-cli/src/components/ExampleFetchComponent/ExampleFetchComponent.tsx b/packages/techdocs-cli/src/components/ExampleFetchComponent/ExampleFetchComponent.tsx similarity index 100% rename from packages/techdocs-cli/techdocs-cli/src/components/ExampleFetchComponent/ExampleFetchComponent.tsx rename to packages/techdocs-cli/src/components/ExampleFetchComponent/ExampleFetchComponent.tsx diff --git a/packages/techdocs-cli/techdocs-cli/src/components/ExampleFetchComponent/index.ts b/packages/techdocs-cli/src/components/ExampleFetchComponent/index.ts similarity index 100% rename from packages/techdocs-cli/techdocs-cli/src/components/ExampleFetchComponent/index.ts rename to packages/techdocs-cli/src/components/ExampleFetchComponent/index.ts diff --git a/packages/techdocs-cli/techdocs-cli/src/index.ts b/packages/techdocs-cli/src/index.ts similarity index 100% rename from packages/techdocs-cli/techdocs-cli/src/index.ts rename to packages/techdocs-cli/src/index.ts diff --git a/packages/techdocs-cli/techdocs-cli/src/plugin.test.ts b/packages/techdocs-cli/src/plugin.test.ts similarity index 100% rename from packages/techdocs-cli/techdocs-cli/src/plugin.test.ts rename to packages/techdocs-cli/src/plugin.test.ts diff --git a/packages/techdocs-cli/techdocs-cli/src/plugin.ts b/packages/techdocs-cli/src/plugin.ts similarity index 100% rename from packages/techdocs-cli/techdocs-cli/src/plugin.ts rename to packages/techdocs-cli/src/plugin.ts diff --git a/packages/techdocs-cli/techdocs-cli/src/setupTests.ts b/packages/techdocs-cli/src/setupTests.ts similarity index 100% rename from packages/techdocs-cli/techdocs-cli/src/setupTests.ts rename to packages/techdocs-cli/src/setupTests.ts From 7484a2602265a3055406cfd72af6e626a0904049 Mon Sep 17 00:00:00 2001 From: Emma Indal Date: Mon, 22 Jun 2020 14:50:50 +0200 Subject: [PATCH 05/14] fix(techdocs-cli): remove dev folder --- packages/techdocs-cli/dev/index.tsx | 20 -------------------- 1 file changed, 20 deletions(-) delete mode 100644 packages/techdocs-cli/dev/index.tsx diff --git a/packages/techdocs-cli/dev/index.tsx b/packages/techdocs-cli/dev/index.tsx deleted file mode 100644 index 812a5585d4..0000000000 --- a/packages/techdocs-cli/dev/index.tsx +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright 2020 Spotify AB - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { createDevApp } from '@backstage/dev-utils'; -import { plugin } from '../src/plugin'; - -createDevApp().registerPlugin(plugin).render(); From b25d28410cd7eae6f3c23ab11e0ad824fcc5bc00 Mon Sep 17 00:00:00 2001 From: Emma Indal Date: Mon, 22 Jun 2020 14:57:53 +0200 Subject: [PATCH 06/14] fix(techdocs-cli): update package.json --- packages/techdocs-cli/package.json | 139 ++++++++++++++++++++++------- 1 file changed, 107 insertions(+), 32 deletions(-) diff --git a/packages/techdocs-cli/package.json b/packages/techdocs-cli/package.json index e4f9b198e0..cba5b374f6 100644 --- a/packages/techdocs-cli/package.json +++ b/packages/techdocs-cli/package.json @@ -1,47 +1,122 @@ { - "name": "@backstage/plugin-techdocs-cli", + "name": "@backstage/techdocs-cli", + "description": "CLI for running TechDocs locally.", "version": "0.1.1-alpha.9", - "main": "src/index.ts", - "types": "src/index.ts", - "license": "Apache-2.0", "private": true, "publishConfig": { - "access": "public", - "main": "dist/index.esm.js", - "types": "dist/index.d.ts" + "access": "restricted" }, + "repository": { + "type": "git", + "url": "https://github.com/spotify/backstage", + "directory": "packages/techdocs-cli" + }, + "keywords": [ + "backstage", + "techdocs" + ], + "license": "Apache-2.0", + "main": "dist/index.cjs.js", "scripts": { - "build": "backstage-cli plugin:build", - "start": "backstage-cli plugin:serve", + "build": "backstage-cli build --outputs cjs", "lint": "backstage-cli lint", "test": "backstage-cli test", - "diff": "backstage-cli plugin:diff", - "prepack": "backstage-cli prepack", - "postpack": "backstage-cli postpack", - "clean": "backstage-cli clean" + "clean": "backstage-cli clean", + "start": "nodemon --" + }, + "bin": { + "techdocs": "bin/techdocs-cli" }, "dependencies": { - "@backstage/core": "^0.1.1-alpha.9", - "@backstage/theme": "^0.1.1-alpha.9", - "@material-ui/core": "^4.9.1", - "@material-ui/icons": "^4.9.1", - "@material-ui/lab": "4.0.0-alpha.45", - "react": "^16.13.1", - "react-dom": "^16.13.1", - "react-use": "^14.2.0" + "@backstage/config": "0.1.1-alpha.9", + "@backstage/config-loader": "^0.1.1-alpha.9", + "@hot-loader/react-dom": "^16.13.0", + "@lerna/package-graph": "^3.18.5", + "@lerna/project": "^3.18.0", + "@rollup/plugin-commonjs": "^12.0.0", + "@rollup/plugin-json": "^4.0.2", + "@rollup/plugin-node-resolve": "^7.1.1", + "@spotify/eslint-config": "^7.0.1", + "@sucrase/webpack-loader": "^2.0.0", + "@types/start-server-webpack-plugin": "^2.2.0", + "@types/webpack-env": "^1.15.2", + "@types/webpack-node-externals": "^1.7.1", + "bfj": "^7.0.2", + "chalk": "^4.0.0", + "chokidar": "^3.3.1", + "commander": "^4.1.1", + "css-loader": "^3.5.3", + "dashify": "^2.0.0", + "diff": "^4.0.2", + "eslint": "^7.1.0", + "eslint-plugin-import": "^2.20.2", + "eslint-plugin-monorepo": "^0.2.1", + "fork-ts-checker-webpack-plugin": "^4.0.5", + "fs-extra": "^9.0.0", + "handlebars": "^4.7.3", + "html-webpack-plugin": "^4.3.0", + "inquirer": "^7.0.4", + "jest": "^26.0.1", + "jest-css-modules": "^2.1.0", + "jest-esm-transformer": "^1.0.0", + "mini-css-extract-plugin": "^0.9.0", + "ora": "^4.0.3", + "raw-loader": "^4.0.1", + "react": "^16.0.0", + "react-dev-utils": "^10.2.1", + "react-hot-loader": "^4.12.21", + "recursive-readdir": "^2.2.2", + "replace-in-file": "^6.0.0", + "rollup": "2.10.x", + "rollup-plugin-dts": "^1.4.6", + "rollup-plugin-esbuild": "^2.0.0", + "rollup-plugin-image-files": "^1.4.2", + "rollup-plugin-peer-deps-external": "^2.2.2", + "rollup-plugin-postcss": "^3.1.1", + "rollup-plugin-typescript2": "^0.26.0", + "start-server-webpack-plugin": "^2.2.5", + "style-loader": "^1.2.1", + "sucrase": "^3.14.1", + "tar": "^6.0.1", + "ts-jest": "^26.0.0", + "ts-loader": "^7.0.4", + "typescript": "^3.9.3", + "url-loader": "^4.1.0", + "webpack": "^4.41.6", + "webpack-dev-server": "^3.10.3", + "webpack-node-externals": "^1.7.2", + "yaml": "^1.10.0", + "yml-loader": "^2.1.0", + "yn": "^4.0.0" }, "devDependencies": { - "@backstage/cli": "^0.1.1-alpha.9", - "@backstage/dev-utils": "^0.1.1-alpha.9", - "@testing-library/jest-dom": "^5.7.0", - "@testing-library/react": "^9.3.2", - "@testing-library/user-event": "^10.2.4", - "@types/jest": "^25.2.2", - "@types/node": "^12.0.0", - "@types/testing-library__jest-dom": "^5.0.4", - "jest-fetch-mock": "^3.0.3" + "@types/diff": "^4.0.2", + "@types/fs-extra": "^9.0.1", + "@types/html-webpack-plugin": "^3.2.2", + "@types/http-proxy": "^1.17.4", + "@types/inquirer": "^6.5.0", + "@types/mini-css-extract-plugin": "^0.9.1", + "@types/node": "^13.7.2", + "@types/ora": "^3.2.0", + "@types/react-dev-utils": "^9.0.4", + "@types/recursive-readdir": "^2.2.0", + "@types/rollup-plugin-peer-deps-external": "^2.2.0", + "@types/rollup-plugin-postcss": "^2.0.0", + "@types/tar": "^4.0.3", + "@types/webpack": "^4.41.7", + "@types/webpack-dev-server": "^3.10.0", + "del": "^5.1.0", + "nodemon": "^2.0.2", + "ts-node": "^8.6.2", + "zombie": "^6.1.4" }, "files": [ - "dist/**/*.{js,d.ts}" - ] + "bin", + "dist/**/*.js" + ], + "nodemonConfig": { + "watch": "./src", + "exec": "bin/techdocs-cli", + "ext": "ts" + } } From d245aaf39ea175b65d38944da64fe4ecfdc43ab2 Mon Sep 17 00:00:00 2001 From: Emma Indal Date: Mon, 22 Jun 2020 15:00:51 +0200 Subject: [PATCH 07/14] fix(techdocs-cli): delete unused files --- .../ExampleComponent.test.tsx | 34 ------ .../ExampleComponent/ExampleComponent.tsx | 57 --------- .../src/components/ExampleComponent/index.ts | 17 --- .../ExampleFetchComponent.test.tsx | 28 ----- .../ExampleFetchComponent.tsx | 108 ------------------ .../components/ExampleFetchComponent/index.ts | 17 --- packages/techdocs-cli/src/index.ts | 2 - packages/techdocs-cli/src/plugin.test.ts | 23 ---- packages/techdocs-cli/src/plugin.ts | 45 -------- packages/techdocs-cli/src/setupTests.ts | 18 --- 10 files changed, 349 deletions(-) delete mode 100644 packages/techdocs-cli/src/components/ExampleComponent/ExampleComponent.test.tsx delete mode 100644 packages/techdocs-cli/src/components/ExampleComponent/ExampleComponent.tsx delete mode 100644 packages/techdocs-cli/src/components/ExampleComponent/index.ts delete mode 100644 packages/techdocs-cli/src/components/ExampleFetchComponent/ExampleFetchComponent.test.tsx delete mode 100644 packages/techdocs-cli/src/components/ExampleFetchComponent/ExampleFetchComponent.tsx delete mode 100644 packages/techdocs-cli/src/components/ExampleFetchComponent/index.ts delete mode 100644 packages/techdocs-cli/src/plugin.test.ts delete mode 100644 packages/techdocs-cli/src/plugin.ts delete mode 100644 packages/techdocs-cli/src/setupTests.ts diff --git a/packages/techdocs-cli/src/components/ExampleComponent/ExampleComponent.test.tsx b/packages/techdocs-cli/src/components/ExampleComponent/ExampleComponent.test.tsx deleted file mode 100644 index 8a565efcff..0000000000 --- a/packages/techdocs-cli/src/components/ExampleComponent/ExampleComponent.test.tsx +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2020 Spotify AB - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import React from 'react'; -import { render } from '@testing-library/react'; -import mockFetch from 'jest-fetch-mock'; -import ExampleComponent from './ExampleComponent'; -import { ThemeProvider } from '@material-ui/core'; -import { lightTheme } from '@backstage/theme'; - -describe('ExampleComponent', () => { - it('should render', () => { - mockFetch.mockResponse(() => new Promise(() => {})); - const rendered = render( - - - , - ); - expect(rendered.getByText('Welcome to techdocs-cli!')).toBeInTheDocument(); - }); -}); diff --git a/packages/techdocs-cli/src/components/ExampleComponent/ExampleComponent.tsx b/packages/techdocs-cli/src/components/ExampleComponent/ExampleComponent.tsx deleted file mode 100644 index 7aca7453d6..0000000000 --- a/packages/techdocs-cli/src/components/ExampleComponent/ExampleComponent.tsx +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2020 Spotify AB - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import React, { FC } from 'react'; -import { Typography, Grid } from '@material-ui/core'; -import { - InfoCard, - Header, - Page, - pageTheme, - Content, - ContentHeader, - HeaderLabel, - SupportButton, -} from '@backstage/core'; -import ExampleFetchComponent from '../ExampleFetchComponent'; - -const ExampleComponent: FC<{}> = () => ( - -
- - -
- - - A description of your plugin goes here. - - - - - - All content should be wrapped in a card like this. - - - - - - - - -
-); - -export default ExampleComponent; diff --git a/packages/techdocs-cli/src/components/ExampleComponent/index.ts b/packages/techdocs-cli/src/components/ExampleComponent/index.ts deleted file mode 100644 index e785d45082..0000000000 --- a/packages/techdocs-cli/src/components/ExampleComponent/index.ts +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright 2020 Spotify AB - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -export { default } from './ExampleComponent'; diff --git a/packages/techdocs-cli/src/components/ExampleFetchComponent/ExampleFetchComponent.test.tsx b/packages/techdocs-cli/src/components/ExampleFetchComponent/ExampleFetchComponent.test.tsx deleted file mode 100644 index 7fecdc6f11..0000000000 --- a/packages/techdocs-cli/src/components/ExampleFetchComponent/ExampleFetchComponent.test.tsx +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright 2020 Spotify AB - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import React from 'react'; -import { render } from '@testing-library/react'; -import mockFetch from 'jest-fetch-mock'; -import ExampleFetchComponent from './ExampleFetchComponent'; - -describe('ExampleFetchComponent', () => { - it('should render', async () => { - mockFetch.mockResponse(() => new Promise(() => {})); - const rendered = render(); - expect(await rendered.findByTestId('progress')).toBeInTheDocument(); - }); -}); diff --git a/packages/techdocs-cli/src/components/ExampleFetchComponent/ExampleFetchComponent.tsx b/packages/techdocs-cli/src/components/ExampleFetchComponent/ExampleFetchComponent.tsx deleted file mode 100644 index c2139befec..0000000000 --- a/packages/techdocs-cli/src/components/ExampleFetchComponent/ExampleFetchComponent.tsx +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright 2020 Spotify AB - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import React, { FC } from 'react'; -import { makeStyles } from '@material-ui/core/styles'; -import { Table, TableColumn, Progress } from '@backstage/core'; -import Alert from '@material-ui/lab/Alert'; -import { useAsync } from 'react-use'; - -const useStyles = makeStyles({ - avatar: { - height: 32, - width: 32, - borderRadius: '50%', - }, -}); - -type User = { - gender: string; // "male" - name: { - title: string; // "Mr", - first: string; // "Duane", - last: string; // "Reed" - }; - location: object; // {street: {number: 5060, name: "Hickory Creek Dr"}, city: "Albany", state: "New South Wales",…} - email: string; // "duane.reed@example.com" - login: object; // {uuid: "4b785022-9a23-4ab9-8a23-cb3fb43969a9", username: "blackdog796", password: "patch",…} - dob: object; // {date: "1983-06-22T12:30:23.016Z", age: 37} - registered: object; // {date: "2006-06-13T18:48:28.037Z", age: 14} - phone: string; // "07-2154-5651" - cell: string; // "0405-592-879" - id: { - name: string; // "TFN", - value: string; // "796260432" - }; - picture: { medium: string }; // {medium: "https://randomuser.me/api/portraits/men/95.jpg",…} - nat: string; // "AU" -}; - -type DenseTableProps = { - users: User[]; -}; - -export const DenseTable: FC = ({ users }) => { - const classes = useStyles(); - - const columns: TableColumn[] = [ - { title: 'Avatar', field: 'avatar' }, - { title: 'Name', field: 'name' }, - { title: 'Email', field: 'email' }, - { title: 'Nationality', field: 'nationality' }, - ]; - - const data = users.map(user => { - return { - avatar: ( - {user.name.first} - ), - name: `${user.name.first} ${user.name.last}`, - email: user.email, - nationality: user.nat, - }; - }); - - return ( -
- ); -}; - -const ExampleFetchComponent: FC<{}> = () => { - const { value, loading, error } = useAsync(async (): Promise => { - const response = await fetch('https://randomuser.me/api/?results=20'); - const data = await response.json(); - return data.results; - }, []); - - if (loading) { - return ; - } else if (error) { - return {error.message}; - } - - return ; -}; - -export default ExampleFetchComponent; diff --git a/packages/techdocs-cli/src/components/ExampleFetchComponent/index.ts b/packages/techdocs-cli/src/components/ExampleFetchComponent/index.ts deleted file mode 100644 index 28482f9fe1..0000000000 --- a/packages/techdocs-cli/src/components/ExampleFetchComponent/index.ts +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright 2020 Spotify AB - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -export { default } from './ExampleFetchComponent'; diff --git a/packages/techdocs-cli/src/index.ts b/packages/techdocs-cli/src/index.ts index 3a0a0fe2d3..f3b69cc361 100644 --- a/packages/techdocs-cli/src/index.ts +++ b/packages/techdocs-cli/src/index.ts @@ -13,5 +13,3 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -export { plugin } from './plugin'; diff --git a/packages/techdocs-cli/src/plugin.test.ts b/packages/techdocs-cli/src/plugin.test.ts deleted file mode 100644 index 6f385bbe53..0000000000 --- a/packages/techdocs-cli/src/plugin.test.ts +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright 2020 Spotify AB - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { plugin } from './plugin'; - -describe('techdocs-cli', () => { - it('should export plugin', () => { - expect(plugin).toBeDefined(); - }); -}); diff --git a/packages/techdocs-cli/src/plugin.ts b/packages/techdocs-cli/src/plugin.ts deleted file mode 100644 index fcba712d9f..0000000000 --- a/packages/techdocs-cli/src/plugin.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2020 Spotify AB - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * Copyright 2020 Spotify AB - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { createPlugin, createRouteRef } from '@backstage/core'; -import ExampleComponent from './components/ExampleComponent'; - -export const rootRouteRef = createRouteRef({ - path: '/techdocs-cli', - title: 'techdocs-cli', -}); - -export const plugin = createPlugin({ - id: 'techdocs-cli', - register({ router }) { - router.addRoute(rootRouteRef, ExampleComponent); - }, -}); diff --git a/packages/techdocs-cli/src/setupTests.ts b/packages/techdocs-cli/src/setupTests.ts deleted file mode 100644 index e34bc46f4b..0000000000 --- a/packages/techdocs-cli/src/setupTests.ts +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright 2020 Spotify AB - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import '@testing-library/jest-dom'; -require('jest-fetch-mock').enableMocks(); From 9077e12261d811e4c24daa65f47d25cd4e3acdd3 Mon Sep 17 00:00:00 2001 From: Emma Indal Date: Mon, 22 Jun 2020 15:06:30 +0200 Subject: [PATCH 08/14] fix(techdocs-cli): update readme --- packages/techdocs-cli/README.md | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/packages/techdocs-cli/README.md b/packages/techdocs-cli/README.md index f4b9534bfa..d7c17210bd 100644 --- a/packages/techdocs-cli/README.md +++ b/packages/techdocs-cli/README.md @@ -1,13 +1,5 @@ -# techdocs-cli +# TechDocs CLI -Welcome to the techdocs-cli plugin! +Check out the [TechDocs README](https://github.com/spotify/backstage/blob/master/plugins/techdocs/README.md) to learn more. -_This plugin was created through the Backstage CLI_ - -## Getting started - -Your plugin has been added to the example app in this repository, meaning you'll be able to access it by running `yarn start` in the root directory, and then navigating to [/techdocs-cli](http://localhost:3000/techdocs-cli). - -You can also serve the plugin in isolation by running `yarn start` in the plugin directory. -This method of serving the plugin provides quicker iteration speed and a faster startup and hot reloads. -It is only meant for local development, and the setup for it can be found inside the [/dev](/dev) directory. +**WIP: This cli is a work in progress. It is not ready for use yet. Follow our progress on [the Backstage Discord](https://discord.gg/MUpMjP2) under #docs-like-code or on [our GitHub Milestone](https://github.com/spotify/backstage/milestone/15).** From b23a90c4b9cc00184cbd6f3aaf85a638845846bd Mon Sep 17 00:00:00 2001 From: Emma Indal Date: Mon, 22 Jun 2020 15:08:53 +0200 Subject: [PATCH 09/14] fix(techdocs-cli): export module to fix tsc error --- packages/techdocs-cli/src/index.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/techdocs-cli/src/index.ts b/packages/techdocs-cli/src/index.ts index f3b69cc361..a010f4bfe5 100644 --- a/packages/techdocs-cli/src/index.ts +++ b/packages/techdocs-cli/src/index.ts @@ -13,3 +13,5 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +export const techDocsCli = () => {}; From b5dba7fb89cab87b4287aabf80505cf90dbb5be9 Mon Sep 17 00:00:00 2001 From: Emma Indal Date: Mon, 22 Jun 2020 15:13:54 +0200 Subject: [PATCH 10/14] fix(techdocs-cli): pass with no tests --- packages/techdocs-cli/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/techdocs-cli/package.json b/packages/techdocs-cli/package.json index cba5b374f6..5a80926a25 100644 --- a/packages/techdocs-cli/package.json +++ b/packages/techdocs-cli/package.json @@ -20,7 +20,7 @@ "scripts": { "build": "backstage-cli build --outputs cjs", "lint": "backstage-cli lint", - "test": "backstage-cli test", + "test": "backstage-cli test --passWithNoTests", "clean": "backstage-cli clean", "start": "nodemon --" }, From 082219ae41856b3033f04131c5ff25f8906c604b Mon Sep 17 00:00:00 2001 From: Emma Indal Date: Mon, 22 Jun 2020 15:29:03 +0200 Subject: [PATCH 11/14] fix(techdocs-cli): minimize dependencies --- packages/techdocs-cli/package.json | 72 +----------------------------- 1 file changed, 2 insertions(+), 70 deletions(-) diff --git a/packages/techdocs-cli/package.json b/packages/techdocs-cli/package.json index 5a80926a25..f4ccd6b0cd 100644 --- a/packages/techdocs-cli/package.json +++ b/packages/techdocs-cli/package.json @@ -28,87 +28,19 @@ "techdocs": "bin/techdocs-cli" }, "dependencies": { - "@backstage/config": "0.1.1-alpha.9", - "@backstage/config-loader": "^0.1.1-alpha.9", - "@hot-loader/react-dom": "^16.13.0", - "@lerna/package-graph": "^3.18.5", - "@lerna/project": "^3.18.0", - "@rollup/plugin-commonjs": "^12.0.0", - "@rollup/plugin-json": "^4.0.2", - "@rollup/plugin-node-resolve": "^7.1.1", - "@spotify/eslint-config": "^7.0.1", - "@sucrase/webpack-loader": "^2.0.0", - "@types/start-server-webpack-plugin": "^2.2.0", - "@types/webpack-env": "^1.15.2", - "@types/webpack-node-externals": "^1.7.1", - "bfj": "^7.0.2", "chalk": "^4.0.0", - "chokidar": "^3.3.1", "commander": "^4.1.1", - "css-loader": "^3.5.3", "dashify": "^2.0.0", - "diff": "^4.0.2", - "eslint": "^7.1.0", - "eslint-plugin-import": "^2.20.2", - "eslint-plugin-monorepo": "^0.2.1", - "fork-ts-checker-webpack-plugin": "^4.0.5", - "fs-extra": "^9.0.0", - "handlebars": "^4.7.3", - "html-webpack-plugin": "^4.3.0", "inquirer": "^7.0.4", "jest": "^26.0.1", - "jest-css-modules": "^2.1.0", - "jest-esm-transformer": "^1.0.0", - "mini-css-extract-plugin": "^0.9.0", - "ora": "^4.0.3", - "raw-loader": "^4.0.1", - "react": "^16.0.0", - "react-dev-utils": "^10.2.1", - "react-hot-loader": "^4.12.21", - "recursive-readdir": "^2.2.2", - "replace-in-file": "^6.0.0", - "rollup": "2.10.x", - "rollup-plugin-dts": "^1.4.6", - "rollup-plugin-esbuild": "^2.0.0", - "rollup-plugin-image-files": "^1.4.2", - "rollup-plugin-peer-deps-external": "^2.2.2", - "rollup-plugin-postcss": "^3.1.1", - "rollup-plugin-typescript2": "^0.26.0", - "start-server-webpack-plugin": "^2.2.5", - "style-loader": "^1.2.1", - "sucrase": "^3.14.1", - "tar": "^6.0.1", - "ts-jest": "^26.0.0", - "ts-loader": "^7.0.4", - "typescript": "^3.9.3", - "url-loader": "^4.1.0", - "webpack": "^4.41.6", - "webpack-dev-server": "^3.10.3", - "webpack-node-externals": "^1.7.2", - "yaml": "^1.10.0", - "yml-loader": "^2.1.0", - "yn": "^4.0.0" + "ora": "^4.0.3" }, "devDependencies": { - "@types/diff": "^4.0.2", - "@types/fs-extra": "^9.0.1", - "@types/html-webpack-plugin": "^3.2.2", - "@types/http-proxy": "^1.17.4", "@types/inquirer": "^6.5.0", - "@types/mini-css-extract-plugin": "^0.9.1", "@types/node": "^13.7.2", "@types/ora": "^3.2.0", - "@types/react-dev-utils": "^9.0.4", - "@types/recursive-readdir": "^2.2.0", - "@types/rollup-plugin-peer-deps-external": "^2.2.0", - "@types/rollup-plugin-postcss": "^2.0.0", - "@types/tar": "^4.0.3", - "@types/webpack": "^4.41.7", - "@types/webpack-dev-server": "^3.10.0", - "del": "^5.1.0", "nodemon": "^2.0.2", - "ts-node": "^8.6.2", - "zombie": "^6.1.4" + "ts-node": "^8.6.2" }, "files": [ "bin", From 54735dc269b94cd1bc2317a30ec0f3f56e58d5dd Mon Sep 17 00:00:00 2001 From: Emma Indal Date: Mon, 22 Jun 2020 16:06:34 +0200 Subject: [PATCH 12/14] fix(techdocs-cli): add techdocs cli bin --- packages/techdocs-cli/bin/techdocs-cli | 34 ++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100755 packages/techdocs-cli/bin/techdocs-cli diff --git a/packages/techdocs-cli/bin/techdocs-cli b/packages/techdocs-cli/bin/techdocs-cli new file mode 100755 index 0000000000..8581750373 --- /dev/null +++ b/packages/techdocs-cli/bin/techdocs-cli @@ -0,0 +1,34 @@ +#!/usr/bin/env node +/* + * Copyright 2020 Spotify AB + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +const path = require('path'); + +// Figure out whether we're running inside the backstage repo or as an installed dependency +const isLocal = require('fs').existsSync(path.resolve(__dirname, '../src')); + +if (!isLocal) { + require('..'); +} else { + require('ts-node').register({ + transpileOnly: true, + compilerOptions: { + module: 'CommonJS', + }, + }); + + require('../src'); +} From 474b1ecf9b831c6eaf11fd1af2bf8defcd3ed13c Mon Sep 17 00:00:00 2001 From: Emma Indal Date: Mon, 22 Jun 2020 16:17:30 +0200 Subject: [PATCH 13/14] fix(techdocs-cli): remove dependencies --- packages/techdocs-cli/package.json | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/packages/techdocs-cli/package.json b/packages/techdocs-cli/package.json index f4ccd6b0cd..4996f6efb4 100644 --- a/packages/techdocs-cli/package.json +++ b/packages/techdocs-cli/package.json @@ -27,20 +27,8 @@ "bin": { "techdocs": "bin/techdocs-cli" }, - "dependencies": { - "chalk": "^4.0.0", - "commander": "^4.1.1", - "dashify": "^2.0.0", - "inquirer": "^7.0.4", - "jest": "^26.0.1", - "ora": "^4.0.3" - }, "devDependencies": { - "@types/inquirer": "^6.5.0", - "@types/node": "^13.7.2", - "@types/ora": "^3.2.0", - "nodemon": "^2.0.2", - "ts-node": "^8.6.2" + "@backstage/cli": "^0.1.1-alpha.9" }, "files": [ "bin", From 55be200b7041332520ad0a1c337e921c5cae2433 Mon Sep 17 00:00:00 2001 From: Emma Indal Date: Mon, 22 Jun 2020 20:33:52 +0200 Subject: [PATCH 14/14] feat(techdocs-cli): change access from restricted to public --- packages/techdocs-cli/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/techdocs-cli/package.json b/packages/techdocs-cli/package.json index 4996f6efb4..927d9477d8 100644 --- a/packages/techdocs-cli/package.json +++ b/packages/techdocs-cli/package.json @@ -4,7 +4,7 @@ "version": "0.1.1-alpha.9", "private": true, "publishConfig": { - "access": "restricted" + "access": "public" }, "repository": { "type": "git",