@backstage/cli 0.8.1 → 0.10.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.
Files changed (60) hide show
  1. package/CHANGELOG.md +73 -0
  2. package/config/jest.js +1 -0
  3. package/config/jestSucraseTransform.js +5 -1
  4. package/dist/cjs/{build-32289a53.cjs.js → build-555a7349.cjs.js} +3 -3
  5. package/dist/cjs/{build-7357e33b.cjs.js → build-8652aa69.cjs.js} +3 -3
  6. package/dist/cjs/{build-036a2109.cjs.js → build-b5fb2b35.cjs.js} +3 -3
  7. package/dist/cjs/{build-3192edeb.cjs.js → build-be463597.cjs.js} +8 -5
  8. package/dist/cjs/{buildWorkspace-794159d5.cjs.js → buildWorkspace-79c93924.cjs.js} +4 -4
  9. package/dist/cjs/{bump-ab142f88.cjs.js → bump-53a961f8.cjs.js} +28 -6
  10. package/dist/cjs/{bundle-faf5ad1e.cjs.js → bundle-64a797f5.cjs.js} +5 -5
  11. package/dist/cjs/{clean-e96f4b94.cjs.js → clean-a28705b5.cjs.js} +2 -2
  12. package/dist/cjs/{config-dab34362.cjs.js → config-3816244a.cjs.js} +21 -6
  13. package/dist/cjs/create-d5e65154.cjs.js +483 -0
  14. package/dist/cjs/{createPlugin-3c802c14.cjs.js → createPlugin-77a95bbd.cjs.js} +8 -9
  15. package/dist/cjs/{dev-5750e5cb.cjs.js → dev-3b68b882.cjs.js} +4 -4
  16. package/dist/cjs/{diff-86e1188b.cjs.js → diff-7238cc6c.cjs.js} +2 -2
  17. package/dist/cjs/{docs-34d3c7fe.cjs.js → docs-f46d6945.cjs.js} +3 -3
  18. package/dist/cjs/{index-69ec4ee3.cjs.js → index-05328067.cjs.js} +13 -11
  19. package/dist/cjs/{index-1db5f8d6.cjs.js → index-8a512334.cjs.js} +169 -51
  20. package/dist/cjs/{index-dc92c8f4.cjs.js → index-c8a3517a.cjs.js} +2 -2
  21. package/dist/cjs/{info-f1a293c8.cjs.js → info-a069f3b4.cjs.js} +3 -3
  22. package/dist/cjs/{install-40b1f07e.cjs.js → install-43a8076b.cjs.js} +4 -4
  23. package/dist/cjs/{lint-95a1066a.cjs.js → lint-0053aded.cjs.js} +3 -3
  24. package/dist/cjs/{lint-73e3cf0a.cjs.js → lint-60658813.cjs.js} +3 -3
  25. package/dist/cjs/{pack-a254b380.cjs.js → pack-a4246579.cjs.js} +2 -2
  26. package/dist/cjs/{packager-679f1af5.cjs.js → packager-b1a183ad.cjs.js} +2 -2
  27. package/dist/cjs/{packages-4fe3897c.cjs.js → packages-562fcd14.cjs.js} +3 -3
  28. package/dist/cjs/{paths-9f678df9.cjs.js → paths-f77bdf66.cjs.js} +20 -5
  29. package/dist/cjs/{print-b972c130.cjs.js → print-db876002.cjs.js} +5 -4
  30. package/dist/cjs/{removePlugin-dc596b42.cjs.js → removePlugin-1379b63a.cjs.js} +6 -3
  31. package/dist/cjs/{run-a312f9a6.cjs.js → run-bacdaaf1.cjs.js} +2 -2
  32. package/dist/cjs/{schema-463ba3bd.cjs.js → schema-3fe57ce7.cjs.js} +3 -3
  33. package/dist/cjs/{serve-7b531df5.cjs.js → serve-a9cf4184.cjs.js} +6 -6
  34. package/dist/cjs/{serve-3d293027.cjs.js → serve-e89d4ea4.cjs.js} +7 -7
  35. package/dist/cjs/{server-5582cec8.cjs.js → server-4f0e40d3.cjs.js} +2 -2
  36. package/dist/cjs/{tasks-d6b72c3c.cjs.js → tasks-29b7d09e.cjs.js} +78 -12
  37. package/dist/cjs/{testCommand-42b484a8.cjs.js → testCommand-5602a58f.cjs.js} +3 -3
  38. package/dist/cjs/{validate-4b57eb89.cjs.js → validate-9b1a5456.cjs.js} +5 -4
  39. package/dist/index.cjs.js +1 -1
  40. package/package.json +18 -18
  41. package/templates/default-backend-plugin/package.json.hbs +39 -37
  42. package/templates/default-backend-plugin/src/run.ts.hbs +1 -1
  43. package/templates/default-common-plugin-package/.eslintrc.js +3 -0
  44. package/templates/default-common-plugin-package/README.md.hbs +5 -0
  45. package/templates/default-common-plugin-package/package.json.hbs +34 -0
  46. package/templates/default-common-plugin-package/src/index.ts.hbs +19 -0
  47. package/templates/default-common-plugin-package/src/setupTests.ts +1 -0
  48. package/templates/default-common-plugin-package/tsconfig.json +9 -0
  49. package/templates/default-plugin/package.json.hbs +4 -2
  50. package/templates/default-plugin/src/routes.ts.hbs +1 -1
  51. package/templates/scaffolder-module/.eslintrc.js +3 -0
  52. package/templates/scaffolder-module/README.md.hbs +5 -0
  53. package/templates/scaffolder-module/package.json.hbs +37 -0
  54. package/templates/scaffolder-module/src/actions/example/example.test.ts +50 -0
  55. package/templates/scaffolder-module/src/actions/example/example.ts +57 -0
  56. package/templates/scaffolder-module/src/actions/example/index.ts +1 -0
  57. package/templates/scaffolder-module/src/actions/index.ts +1 -0
  58. package/templates/scaffolder-module/src/index.ts.hbs +8 -0
  59. package/templates/scaffolder-module/tsconfig.json +9 -0
  60. package/dist/cjs/buildImage-62344040.cjs.js +0 -77
@@ -0,0 +1,50 @@
1
+ /*
2
+ * Copyright 2021 The Backstage Authors
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import { PassThrough } from 'stream';
18
+ import { createAcmeExampleAction } from './example';
19
+ import { getVoidLogger } from '@backstage/backend-common';
20
+
21
+ describe('acme:example', () => {
22
+ afterEach(() => {
23
+ jest.resetAllMocks();
24
+ });
25
+
26
+ it('should call action', async () => {
27
+ const action = createAcmeExampleAction();
28
+
29
+ const logger = getVoidLogger();
30
+ jest.spyOn(logger, 'info');
31
+
32
+ await action.handler({
33
+ input: {
34
+ myParameter: 'test',
35
+ },
36
+ workspacePath: '/tmp',
37
+ logger,
38
+ logStream: new PassThrough(),
39
+ output: jest.fn(),
40
+ createTemporaryDirectory() {
41
+ // Usage of mock-fs is recommended for testing of filesystem operations
42
+ throw new Error('Not implemented');
43
+ },
44
+ });
45
+
46
+ expect(logger.info).toHaveBeenCalledWith(
47
+ 'Running example template with parameters: test',
48
+ );
49
+ });
50
+ });
@@ -0,0 +1,57 @@
1
+ /*
2
+ * Copyright 2021 The Backstage Authors
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import { createTemplateAction } from '@backstage/plugin-scaffolder-backend';
18
+
19
+ /**
20
+ * Creates an `acme:example` Scaffolder action.
21
+ *
22
+ * @remarks
23
+ *
24
+ * See {@link https://example.com} for more information.
25
+ *
26
+ * @public
27
+ */
28
+ export function createAcmeExampleAction() {
29
+ // For more information on how to define custom actions, see
30
+ // https://backstage.io/docs/features/software-templates/writing-custom-actions
31
+ return createTemplateAction<{
32
+ myParameter: string;
33
+ }>({
34
+ id: 'acme:example',
35
+ description: 'Runs Yeoman on an installed Yeoman generator',
36
+ schema: {
37
+ input: {
38
+ type: 'object',
39
+ required: ['myParameter'],
40
+ properties: {
41
+ myParameter: {
42
+ title: 'An example parameter',
43
+ description: 'This is the schema for our example parameter',
44
+ type: 'string',
45
+ },
46
+ },
47
+ },
48
+ },
49
+ async handler(ctx) {
50
+ ctx.logger.info(
51
+ `Running example template with parameters: ${ctx.input.myParameter}`,
52
+ );
53
+
54
+ await new Promise(resolve => setTimeout(resolve, 1000));
55
+ },
56
+ });
57
+ }
@@ -0,0 +1 @@
1
+ export { createAcmeExampleAction } from './example';
@@ -0,0 +1 @@
1
+ export * from './example';
@@ -0,0 +1,8 @@
1
+ /***/
2
+ /**
3
+ * The {{id}} module for @backstage/plugin-scaffolder-backend.
4
+ *
5
+ * @packageDocumentation
6
+ */
7
+
8
+ export * from './actions';
@@ -0,0 +1,9 @@
1
+ {
2
+ "extends": "@backstage/cli/config/tsconfig.json",
3
+ "include": ["src"],
4
+ "exclude": ["node_modules"],
5
+ "compilerOptions": {
6
+ "outDir": "dist-types",
7
+ "rootDir": "."
8
+ }
9
+ }
@@ -1,77 +0,0 @@
1
- 'use strict';
2
-
3
- var chalk = require('chalk');
4
- var fs = require('fs-extra');
5
- var path = require('path');
6
- var index$1 = require('./index-69ec4ee3.cjs.js');
7
- var index = require('./index-1db5f8d6.cjs.js');
8
- var run = require('./run-a312f9a6.cjs.js');
9
- var parallel = require('./parallel-a4714c72.cjs.js');
10
- require('os');
11
- require('tar');
12
- require('commander');
13
- require('semver');
14
- require('@backstage/cli-common');
15
- require('@backstage/config/package.json');
16
- require('@backstage/errors');
17
- require('child_process');
18
- require('util');
19
-
20
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
21
-
22
- var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
23
-
24
- const PKG_PATH = "package.json";
25
- var buildImage = async (cmd) => {
26
- if (cmd.args.includes("--help")) {
27
- await run.run("docker", ["image", "build", "--help"]);
28
- return;
29
- }
30
- console.warn(chalk.yellow(`
31
- The backend:build-image command is deprecated and will be removed in the future.
32
- Please use the backend:bundle command instead along with your own Docker setup.
33
-
34
- https://backstage.io/docs/deployment/docker
35
- `));
36
- const pkgPath = index.paths.resolveTarget(PKG_PATH);
37
- const pkg = await fs__default['default'].readJson(pkgPath);
38
- const appConfigs = await findAppConfigs();
39
- const npmrc = await fs__default['default'].pathExists(index.paths.resolveTargetRoot(".npmrc")) ? [".npmrc"] : [];
40
- const tempDistWorkspace = await index$1.createDistWorkspace([pkg.name], {
41
- buildDependencies: Boolean(cmd.build),
42
- files: [
43
- "package.json",
44
- "yarn.lock",
45
- ...npmrc,
46
- ...appConfigs,
47
- {src: index.paths.resolveTarget("Dockerfile"), dest: "Dockerfile"}
48
- ],
49
- parallel: parallel.parseParallel(process.env[parallel.PARALLEL_ENV_VAR]),
50
- skeleton: "skeleton.tar"
51
- });
52
- console.log(`Dist workspace ready at ${tempDistWorkspace}`);
53
- await run.run("docker", ["image", "build", ".", ...cmd.args], {
54
- cwd: tempDistWorkspace
55
- });
56
- await fs__default['default'].remove(tempDistWorkspace);
57
- };
58
- async function findAppConfigs() {
59
- const files = [];
60
- for (const name of await fs__default['default'].readdir(index.paths.targetRoot)) {
61
- if (name.startsWith("app-config.") && name.endsWith(".yaml")) {
62
- files.push(name);
63
- }
64
- }
65
- if (index.paths.targetRoot !== index.paths.targetDir) {
66
- const dirPath = path.relative(index.paths.targetRoot, index.paths.targetDir);
67
- for (const name of await fs__default['default'].readdir(index.paths.targetDir)) {
68
- if (name.startsWith("app-config.") && name.endsWith(".yaml")) {
69
- files.push(path.join(dirPath, name));
70
- }
71
- }
72
- }
73
- return files;
74
- }
75
-
76
- exports.default = buildImage;
77
- //# sourceMappingURL=buildImage-62344040.cjs.js.map