@backstage/repo-tools 0.12.0-next.0 → 0.12.0-next.2

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 CHANGED
@@ -1,5 +1,31 @@
1
1
  # @backstage/repo-tools
2
2
 
3
+ ## 0.12.0-next.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+ - @backstage/backend-plugin-api@1.1.0-next.2
9
+ - @backstage/errors@1.2.6-next.0
10
+ - @backstage/cli-node@0.2.11-next.1
11
+ - @backstage/config-loader@1.9.3-next.1
12
+ - @backstage/catalog-model@1.7.2-next.0
13
+ - @backstage/cli-common@0.1.15
14
+
15
+ ## 0.12.0-next.1
16
+
17
+ ### Patch Changes
18
+
19
+ - 860e3b5: Generated OpenAPI clients now support paths with tags.
20
+ - 00058d0: The `generate-patch` command will now add a single resolution entry for all versions of the patched package, rather than separate entries for each version query.
21
+ - Updated dependencies
22
+ - @backstage/config-loader@1.9.3-next.0
23
+ - @backstage/backend-plugin-api@1.1.0-next.1
24
+ - @backstage/catalog-model@1.7.1
25
+ - @backstage/cli-common@0.1.15
26
+ - @backstage/cli-node@0.2.11-next.0
27
+ - @backstage/errors@1.2.5
28
+
3
29
  ## 0.12.0-next.0
4
30
 
5
31
  ### Minor Changes
@@ -121,7 +121,6 @@ async function loadTrimmedRootPkg(ctx, query) {
121
121
  );
122
122
  };
123
123
  }
124
- const resolutionMap = await readResolutionMap(ctx);
125
124
  const entriesToRemove = Object.entries(resolutionsObj).filter(
126
125
  ([key]) => key.startsWith(`${ctx.packageName}@`)
127
126
  );
@@ -134,24 +133,8 @@ async function loadTrimmedRootPkg(ctx, query) {
134
133
  });
135
134
  }
136
135
  }
137
- const descriptors = new Array();
138
- for (const [descriptor, locator] of resolutionMap) {
139
- if (!locator.includes("@npm:")) {
140
- if (!locator.includes("@virtual:")) {
141
- console.warn(`Skipping resolution for ${descriptor}, no version found`);
142
- }
143
- continue;
144
- }
145
- descriptors.push(descriptor);
146
- }
147
136
  return async (patchEntry) => {
148
- if (descriptors.length > 0) {
149
- for (const descriptor of descriptors) {
150
- resolutionsObj[descriptor] = patchEntry;
151
- }
152
- } else {
153
- resolutionsObj[ctx.packageName] = patchEntry;
154
- }
137
+ resolutionsObj[ctx.packageName] = patchEntry;
155
138
  await fs__default.default.writeJson(
156
139
  path.resolve(ctx.targetRoot, "package.json"),
157
140
  newPkgJson,
@@ -208,34 +191,6 @@ function tryParsePatchResolution(value) {
208
191
  const patchFilePath = value.split("#")[1];
209
192
  return patchFilePath;
210
193
  }
211
- async function readResolutionMap(ctx) {
212
- const { stdout: whyOutput } = await exec.exec(
213
- "yarn",
214
- ["why", "--json", ctx.packageName],
215
- {
216
- cwd: ctx.targetRoot,
217
- maxBuffer: 64 * 1024 * 1024
218
- }
219
- );
220
- const resolutionMap = /* @__PURE__ */ new Map();
221
- for (const line of whyOutput.toString("utf8").trim().split(/\r?\n/)) {
222
- for (const { locator, descriptor } of Object.values(
223
- JSON.parse(line).children
224
- )) {
225
- const existing = resolutionMap.get(descriptor);
226
- if (existing) {
227
- if (existing !== locator) {
228
- throw new Error(
229
- `Conflicting resolutions in target package for ${descriptor}: ${existing} vs ${locator}`
230
- );
231
- }
232
- } else {
233
- resolutionMap.set(descriptor, locator);
234
- }
235
- }
236
- }
237
- return resolutionMap;
238
- }
239
194
  async function buildTargetArchive(ctx) {
240
195
  await exec.exec("yarn", ["build"], {
241
196
  cwd: ctx.sourcePkg.dir
@@ -20,9 +20,10 @@ async function generate(outputDirectory, clientAdditionalProperties, abortSignal
20
20
  outputDirectory,
21
21
  constants.OUTPUT_PATH
22
22
  );
23
- const additionalProperties = clientAdditionalProperties ? `--additional-properties=${clientAdditionalProperties}` : "";
24
- fs.mkdirpSync(resolvedOutputDirectory);
25
- await fs__default.default.mkdirp(resolvedOutputDirectory);
23
+ const additionalProperties = helpers.toGeneratorAdditionalProperties({
24
+ initialValue: clientAdditionalProperties
25
+ });
26
+ await fs__default.default.emptyDir(resolvedOutputDirectory);
26
27
  await fs__default.default.writeFile(
27
28
  path.resolve(resolvedOutputDirectory, ".openapi-generator-ignore"),
28
29
  constants.OPENAPI_IGNORE_FILES.join("\n")
@@ -45,7 +46,7 @@ async function generate(outputDirectory, clientAdditionalProperties, abortSignal
45
46
  ),
46
47
  "--generator-key",
47
48
  "v3.0",
48
- additionalProperties
49
+ additionalProperties ? `--additional-properties=${additionalProperties}` : ""
49
50
  ],
50
51
  {
51
52
  signal: abortSignal?.signal,
@@ -58,7 +58,7 @@ export const createOpenApiRouter = async (
58
58
  async function generate(abortSignal) {
59
59
  const resolvedOpenapiPath = await helpers.getPathToCurrentOpenApiSpec();
60
60
  const resolvedOutputDirectory = await helpers.getRelativePathToFile(constants.OUTPUT_PATH);
61
- await fs__default.default.mkdirp(resolvedOutputDirectory);
61
+ await fs__default.default.emptyDir(resolvedOutputDirectory);
62
62
  await fs__default.default.writeFile(
63
63
  path.resolve(resolvedOutputDirectory, ".openapi-generator-ignore"),
64
64
  constants.OPENAPI_IGNORE_FILES.join("\n")
@@ -37,6 +37,20 @@ async function loadAndValidateOpenApiYaml(path) {
37
37
  await Parser__default.default.validate(lodash.cloneDeep(yaml));
38
38
  return yaml;
39
39
  }
40
+ function toGeneratorAdditionalProperties({
41
+ initialValue,
42
+ defaultValue
43
+ }) {
44
+ const items = initialValue?.split(",") ?? [];
45
+ const parsed = items.reduce(
46
+ (acc, item) => {
47
+ const [key, value] = item.split("=");
48
+ return { ...acc, [key]: value };
49
+ },
50
+ { ...defaultValue }
51
+ );
52
+ return Object.entries(parsed).map(([key, value]) => `${key}=${value}`).join(",");
53
+ }
40
54
 
41
55
  exports.assertExists = assertExists;
42
56
  exports.getPathToCurrentOpenApiSpec = getPathToCurrentOpenApiSpec;
@@ -44,4 +58,5 @@ exports.getPathToFile = getPathToFile;
44
58
  exports.getPathToOpenApiSpec = getPathToOpenApiSpec;
45
59
  exports.getRelativePathToFile = getRelativePathToFile;
46
60
  exports.loadAndValidateOpenApiYaml = loadAndValidateOpenApiYaml;
61
+ exports.toGeneratorAdditionalProperties = toGeneratorAdditionalProperties;
47
62
  //# sourceMappingURL=helpers.cjs.js.map
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var version = "0.12.0-next.0";
3
+ var version = "0.12.0-next.2";
4
4
 
5
5
  exports.version = version;
6
6
  //# sourceMappingURL=package.json.cjs.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/repo-tools",
3
- "version": "0.12.0-next.0",
3
+ "version": "0.12.0-next.2",
4
4
  "description": "CLI for Backstage repo tooling ",
5
5
  "backstage": {
6
6
  "role": "cli"
@@ -43,12 +43,12 @@
43
43
  "dependencies": {
44
44
  "@apidevtools/swagger-parser": "^10.1.0",
45
45
  "@apisyouwonthate/style-guide": "^1.4.0",
46
- "@backstage/backend-plugin-api": "1.0.3-next.0",
47
- "@backstage/catalog-model": "1.7.1",
46
+ "@backstage/backend-plugin-api": "1.1.0-next.2",
47
+ "@backstage/catalog-model": "1.7.2-next.0",
48
48
  "@backstage/cli-common": "0.1.15",
49
- "@backstage/cli-node": "0.2.11-next.0",
50
- "@backstage/config-loader": "1.9.2",
51
- "@backstage/errors": "1.2.5",
49
+ "@backstage/cli-node": "0.2.11-next.1",
50
+ "@backstage/config-loader": "1.9.3-next.1",
51
+ "@backstage/errors": "1.2.6-next.0",
52
52
  "@manypkg/get-packages": "^1.1.3",
53
53
  "@microsoft/api-documenter": "^7.25.7",
54
54
  "@microsoft/api-extractor": "^7.47.2",
@@ -79,8 +79,8 @@
79
79
  "yaml-diff-patch": "^2.0.0"
80
80
  },
81
81
  "devDependencies": {
82
- "@backstage/backend-test-utils": "1.2.0-next.0",
83
- "@backstage/cli": "0.29.3-next.0",
82
+ "@backstage/backend-test-utils": "1.2.0-next.2",
83
+ "@backstage/cli": "0.29.3-next.2",
84
84
  "@backstage/types": "1.2.0",
85
85
  "@types/is-glob": "^4.0.2",
86
86
  "@types/node": "^20.16.0",
@@ -4,10 +4,12 @@ import { FetchApi } from '../types/fetch';
4
4
  import crossFetch from 'cross-fetch';
5
5
  import {pluginId} from '../pluginId';
6
6
  import * as parser from 'uri-template';
7
-
7
+ {{#apiInfo}}
8
+ {{#apis}}
8
9
  {{#imports}}
9
10
  import { {{classname}} } from '{{filename}}.model{{importFileExtension}}';
10
11
  {{/imports}}
12
+ {{/apis}}
11
13
 
12
14
  /**
13
15
  * Wraps the Response type to convey a type on the json call.
@@ -18,8 +20,6 @@ export type TypedResponse<T> = Omit<Response, 'json'> & {
18
20
  json: () => Promise<T>;
19
21
  };
20
22
 
21
- {{#operations}}
22
-
23
23
  /**
24
24
  * Options you can pass into a request for additional information.
25
25
  *
@@ -28,7 +28,8 @@ export type TypedResponse<T> = Omit<Response, 'json'> & {
28
28
  export interface RequestOptions {
29
29
  token?: string;
30
30
  }
31
-
31
+ {{#apis}}
32
+ {{#operations}}
32
33
  {{#operation}}
33
34
  /**
34
35
  * @public
@@ -62,12 +63,13 @@ export type {{#lambda.pascalcase}}{{nickname}}{{/lambda.pascalcase}} = {
62
63
  {{/hasHeaderParams}}
63
64
  }
64
65
  {{/operation}}
66
+ {{/operations}}
67
+ {{/apis}}
65
68
 
66
69
  /**
67
- * {{{description}}}{{^description}}no description{{/description}}
68
70
  * @public
69
71
  */
70
- export class {{classname}}Client {
72
+ export class DefaultApiClient {
71
73
  private readonly discoveryApi: DiscoveryApi;
72
74
  private readonly fetchApi: FetchApi;
73
75
 
@@ -79,6 +81,9 @@ export class {{classname}}Client {
79
81
  this.fetchApi = options.fetchApi || { fetch: crossFetch };
80
82
  }
81
83
 
84
+ {{#apis}}
85
+ {{#operations}}
86
+
82
87
  {{#operation}}
83
88
  /**
84
89
  {{#notes}}
@@ -123,5 +128,7 @@ export class {{classname}}Client {
123
128
  }
124
129
 
125
130
  {{/operation}}
131
+ {{/operations}}
132
+ {{/apis}}
126
133
  }
127
- {{/operations}}
134
+ {{/apiInfo}}
@@ -1,3 +1,3 @@
1
1
  //
2
2
 
3
- export * from './DefaultApi.client';
3
+ export * from './Api.client';
@@ -1,10 +1,6 @@
1
1
  templateDir: templates/typescript-backstage-client
2
2
 
3
3
  files:
4
- api.mustache:
5
- templateType: API
6
- # For some reason, they check for destinationFilename differences. We have to change the ending to override the file.
7
- destinationFilename: .client.ts
8
4
  model.mustache:
9
5
  templateType: Model
10
6
  destinationFilename: .model.ts
@@ -32,6 +28,9 @@ files:
32
28
  apis/index.mustache:
33
29
  templateType: SupportingFiles
34
30
  destinationFilename: apis/index.ts
31
+ apis/api-all.mustache:
32
+ templateType: SupportingFiles
33
+ destinationFilename: apis/Api.client.ts
35
34
  pluginId.mustache:
36
35
  templateType: SupportingFiles
37
36
  destinationFilename: pluginId.ts
@@ -1,4 +1,7 @@
1
+ //
1
2
  {{>licenseInfo}}
3
+ {{#apiInfo}}
4
+ {{#apis}}
2
5
  {{#imports}}
3
6
  import { {{classname}} } from '{{filename}}.model{{importFileExtension}}';
4
7
  {{/imports}}
@@ -39,16 +42,19 @@ export type {{#lambda.pascalcase}}{{nickname}}{{/lambda.pascalcase}} = {
39
42
  response: {{#responses}} {{{dataType}}}{{^dataType}}void{{/dataType}} {{^-last}} | {{/-last}} {{/responses}}
40
43
  }
41
44
  {{/operation}}
42
-
43
- /**
44
- * {{{description}}}{{^description}}no description{{/description}}
45
- */
45
+ {{/operations}}
46
+ {{/apis}}
46
47
 
47
48
  export type EndpointMap = {
49
+ {{#apis}}
50
+ {{#operations}}
48
51
  {{#operation}}
49
52
 
50
53
  '#{{#lambda.lowercase}}{{httpMethod}}{{/lambda.lowercase}}|{{path}}': {{#lambda.pascalcase}}{{nickname}}{{/lambda.pascalcase}},
51
54
 
52
55
  {{/operation}}
56
+ {{/operations}}
57
+ {{/apis}}
53
58
  }
54
- {{/operations}}
59
+
60
+ {{/apiInfo}}
@@ -1,3 +1,4 @@
1
1
  //
2
+ {{>licenseInfo}}
2
3
 
3
- export * from './DefaultApi.server';
4
+ export * from './Api.server'
@@ -1,13 +1,12 @@
1
1
  templateDir: templates/typescript-backstage-server
2
2
 
3
3
  files:
4
- api.mustache:
5
- templateType: API
6
- # For some reason, they check for destinationFilename differences. We have to change the ending to override the file.
7
- destinationFilename: .server.ts
8
4
  apis/index.mustache:
9
5
  templateType: SupportingFiles
10
6
  destinationFilename: apis/index.ts
7
+ apis/api-all.mustache:
8
+ templateType: SupportingFiles
9
+ destinationFilename: apis/Api.server.ts
11
10
  index.mustache:
12
11
  templateType: SupportingFiles
13
12
  destinationFilename: index.ts