@backstage/cli-module-config 0.0.0-nightly-20260317031259
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 +16 -0
- package/README.md +18 -0
- package/bin/backstage-cli-module-config +32 -0
- package/dist/commands/docs.cjs.js +63 -0
- package/dist/commands/docs.cjs.js.map +1 -0
- package/dist/commands/print.cjs.js +81 -0
- package/dist/commands/print.cjs.js.map +1 -0
- package/dist/commands/schema.cjs.js +56 -0
- package/dist/commands/schema.cjs.js.map +1 -0
- package/dist/commands/validate.cjs.js +50 -0
- package/dist/commands/validate.cjs.js.map +1 -0
- package/dist/index.cjs.js +45 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/lib/config.cjs.js +94 -0
- package/dist/lib/config.cjs.js.map +1 -0
- package/dist/package.json.cjs.js +89 -0
- package/dist/package.json.cjs.js.map +1 -0
- package/package.json +59 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# @backstage/cli-module-config
|
|
2
|
+
|
|
3
|
+
## 0.0.0-nightly-20260317031259
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 329f394: Initial release of the CLI module packages. Each module provides a set of commands that can be discovered automatically by `@backstage/cli` or executed standalone.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
- @backstage/cli-node@0.0.0-nightly-20260317031259
|
|
13
|
+
- @backstage/cli-common@0.0.0-nightly-20260317031259
|
|
14
|
+
- @backstage/config-loader@0.0.0-nightly-20260317031259
|
|
15
|
+
- @backstage/config@1.3.6
|
|
16
|
+
- @backstage/types@1.2.2
|
package/README.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# @backstage/cli-module-config
|
|
2
|
+
|
|
3
|
+
CLI module that provides configuration inspection commands for the Backstage CLI.
|
|
4
|
+
|
|
5
|
+
## Commands
|
|
6
|
+
|
|
7
|
+
| Command | Description |
|
|
8
|
+
| :-------------- | :------------------------------------------------------------- |
|
|
9
|
+
| `config docs` | Browse the configuration reference documentation |
|
|
10
|
+
| `config:print` | Print the app configuration for the current package |
|
|
11
|
+
| `config:check` | Validate that the given configuration loads and matches schema |
|
|
12
|
+
| `config schema` | Print the JSON schema for the given configuration |
|
|
13
|
+
|
|
14
|
+
## Documentation
|
|
15
|
+
|
|
16
|
+
- [Backstage Readme](https://github.com/backstage/backstage/blob/master/README.md)
|
|
17
|
+
- [Backstage Documentation](https://backstage.io/docs)
|
|
18
|
+
- [Static Configuration](https://backstage.io/docs/conf/)
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2024 The Backstage Authors
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
const path = require('node:path');
|
|
19
|
+
|
|
20
|
+
/* eslint-disable-next-line no-restricted-syntax */
|
|
21
|
+
const isLocal = require('node:fs').existsSync(
|
|
22
|
+
path.resolve(__dirname, '../src'),
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
if (isLocal) {
|
|
26
|
+
require('@backstage/cli-node/config/nodeTransform.cjs');
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const { runCliModule } = require('@backstage/cli-node');
|
|
30
|
+
const cliModule = require(isLocal ? '../src/index' : '..').default;
|
|
31
|
+
const pkg = require('../package.json');
|
|
32
|
+
runCliModule({ module: cliModule, name: pkg.name, version: pkg.version });
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var cleye = require('cleye');
|
|
6
|
+
var configLoader = require('@backstage/config-loader');
|
|
7
|
+
var openBrowser = require('react-dev-utils/openBrowser');
|
|
8
|
+
var chalk = require('chalk');
|
|
9
|
+
var config = require('../lib/config.cjs.js');
|
|
10
|
+
|
|
11
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
12
|
+
|
|
13
|
+
var openBrowser__default = /*#__PURE__*/_interopDefaultCompat(openBrowser);
|
|
14
|
+
var chalk__default = /*#__PURE__*/_interopDefaultCompat(chalk);
|
|
15
|
+
|
|
16
|
+
const DOCS_URL = "https://config.backstage.io";
|
|
17
|
+
var docs = async ({ args, info }) => {
|
|
18
|
+
const {
|
|
19
|
+
flags: { package: pkg }
|
|
20
|
+
} = cleye.cli(
|
|
21
|
+
{
|
|
22
|
+
help: info,
|
|
23
|
+
booleanFlagNegation: true,
|
|
24
|
+
flags: {
|
|
25
|
+
package: {
|
|
26
|
+
type: String,
|
|
27
|
+
description: "Only include the schema that applies to the given package"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
void 0,
|
|
32
|
+
args
|
|
33
|
+
);
|
|
34
|
+
const { schema: appSchemas } = await config.loadCliConfig({
|
|
35
|
+
args: [],
|
|
36
|
+
fromPackage: pkg,
|
|
37
|
+
mockEnv: true
|
|
38
|
+
});
|
|
39
|
+
const schema = configLoader.mergeConfigSchemas(
|
|
40
|
+
appSchemas.serialize().schemas.map(
|
|
41
|
+
(_) => _.value
|
|
42
|
+
)
|
|
43
|
+
);
|
|
44
|
+
const url = `${DOCS_URL}#schema=${JSON.stringify(schema)}`;
|
|
45
|
+
console.log();
|
|
46
|
+
console.log(
|
|
47
|
+
chalk__default.default.cyan(
|
|
48
|
+
"Opening configuration reference documentation in your browser..."
|
|
49
|
+
)
|
|
50
|
+
);
|
|
51
|
+
console.log(` ${chalk__default.default.cyan(url)}`);
|
|
52
|
+
console.log();
|
|
53
|
+
const opened = openBrowser__default.default(url);
|
|
54
|
+
if (!opened) {
|
|
55
|
+
console.log(
|
|
56
|
+
chalk__default.default.yellow("\u26A0\uFE0F WARNING: Unable to open browser automatically.")
|
|
57
|
+
);
|
|
58
|
+
console.log(chalk__default.default.yellow("Please open the URL manually in your browser."));
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
exports.default = docs;
|
|
63
|
+
//# sourceMappingURL=docs.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docs.cjs.js","sources":["../../src/commands/docs.ts"],"sourcesContent":["/*\n * Copyright 2021 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 { cli } from 'cleye';\nimport { JsonObject } from '@backstage/types';\nimport { mergeConfigSchemas } from '@backstage/config-loader';\nimport { JSONSchema7 as JSONSchema } from 'json-schema';\nimport openBrowser from 'react-dev-utils/openBrowser';\nimport chalk from 'chalk';\nimport { loadCliConfig } from '../lib/config';\nimport type { CliCommandContext } from '@backstage/cli-node';\n\nconst DOCS_URL = 'https://config.backstage.io';\n\nexport default async ({ args, info }: CliCommandContext) => {\n const {\n flags: { package: pkg },\n } = cli(\n {\n help: info,\n booleanFlagNegation: true,\n flags: {\n package: {\n type: String,\n description:\n 'Only include the schema that applies to the given package',\n },\n },\n },\n undefined,\n args,\n );\n\n const { schema: appSchemas } = await loadCliConfig({\n args: [],\n fromPackage: pkg,\n mockEnv: true,\n });\n\n const schema = mergeConfigSchemas(\n (appSchemas.serialize().schemas as JsonObject[]).map(\n _ => _.value as JSONSchema,\n ),\n );\n\n const url = `${DOCS_URL}#schema=${JSON.stringify(schema)}`;\n\n console.log();\n console.log(\n chalk.cyan(\n 'Opening configuration reference documentation in your browser...',\n ),\n );\n console.log(` ${chalk.cyan(url)}`);\n console.log();\n\n const opened = openBrowser(url);\n\n if (!opened) {\n console.log(\n chalk.yellow('⚠️ WARNING: Unable to open browser automatically.'),\n );\n console.log(chalk.yellow('Please open the URL manually in your browser.'));\n }\n};\n"],"names":["cli","loadCliConfig","mergeConfigSchemas","chalk","openBrowser"],"mappings":";;;;;;;;;;;;;;;AAyBA,MAAM,QAAA,GAAW,6BAAA;AAEjB,WAAe,OAAO,EAAE,IAAA,EAAM,IAAA,EAAK,KAAyB;AAC1D,EAAA,MAAM;AAAA,IACJ,KAAA,EAAO,EAAE,OAAA,EAAS,GAAA;AAAI,GACxB,GAAIA,SAAA;AAAA,IACF;AAAA,MACE,IAAA,EAAM,IAAA;AAAA,MACN,mBAAA,EAAqB,IAAA;AAAA,MACrB,KAAA,EAAO;AAAA,QACL,OAAA,EAAS;AAAA,UACP,IAAA,EAAM,MAAA;AAAA,UACN,WAAA,EACE;AAAA;AACJ;AACF,KACF;AAAA,IACA,MAAA;AAAA,IACA;AAAA,GACF;AAEA,EAAA,MAAM,EAAE,MAAA,EAAQ,UAAA,EAAW,GAAI,MAAMC,oBAAA,CAAc;AAAA,IACjD,MAAM,EAAC;AAAA,IACP,WAAA,EAAa,GAAA;AAAA,IACb,OAAA,EAAS;AAAA,GACV,CAAA;AAED,EAAA,MAAM,MAAA,GAASC,+BAAA;AAAA,IACZ,UAAA,CAAW,SAAA,EAAU,CAAE,OAAA,CAAyB,GAAA;AAAA,MAC/C,OAAK,CAAA,CAAE;AAAA;AACT,GACF;AAEA,EAAA,MAAM,MAAM,CAAA,EAAG,QAAQ,WAAW,IAAA,CAAK,SAAA,CAAU,MAAM,CAAC,CAAA,CAAA;AAExD,EAAA,OAAA,CAAQ,GAAA,EAAI;AACZ,EAAA,OAAA,CAAQ,GAAA;AAAA,IACNC,sBAAA,CAAM,IAAA;AAAA,MACJ;AAAA;AACF,GACF;AACA,EAAA,OAAA,CAAQ,IAAI,CAAA,EAAA,EAAKA,sBAAA,CAAM,IAAA,CAAK,GAAG,CAAC,CAAA,CAAE,CAAA;AAClC,EAAA,OAAA,CAAQ,GAAA,EAAI;AAEZ,EAAA,MAAM,MAAA,GAASC,6BAAY,GAAG,CAAA;AAE9B,EAAA,IAAI,CAAC,MAAA,EAAQ;AACX,IAAA,OAAA,CAAQ,GAAA;AAAA,MACND,sBAAA,CAAM,OAAO,8DAAoD;AAAA,KACnE;AACA,IAAA,OAAA,CAAQ,GAAA,CAAIA,sBAAA,CAAM,MAAA,CAAO,+CAA+C,CAAC,CAAA;AAAA,EAC3E;AACF,CAAA;;;;"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var cleye = require('cleye');
|
|
6
|
+
var yaml = require('yaml');
|
|
7
|
+
var config$1 = require('@backstage/config');
|
|
8
|
+
var config = require('../lib/config.cjs.js');
|
|
9
|
+
|
|
10
|
+
var print = async ({ args, info }) => {
|
|
11
|
+
const {
|
|
12
|
+
flags: { config: config$1, lax, frontend, withSecrets, format, package: pkg }
|
|
13
|
+
} = cleye.cli(
|
|
14
|
+
{
|
|
15
|
+
help: info,
|
|
16
|
+
booleanFlagNegation: true,
|
|
17
|
+
flags: {
|
|
18
|
+
package: { type: String, description: "Package to print config for" },
|
|
19
|
+
lax: {
|
|
20
|
+
type: Boolean,
|
|
21
|
+
description: "Do not require environment variables to be set"
|
|
22
|
+
},
|
|
23
|
+
frontend: { type: Boolean, description: "Only print frontend config" },
|
|
24
|
+
withSecrets: {
|
|
25
|
+
type: Boolean,
|
|
26
|
+
description: "Include secrets in the output"
|
|
27
|
+
},
|
|
28
|
+
format: { type: String, description: "Output format (yaml or json)" },
|
|
29
|
+
config: {
|
|
30
|
+
type: [String],
|
|
31
|
+
description: "Config files to load instead of app-config.yaml"
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
void 0,
|
|
36
|
+
args
|
|
37
|
+
);
|
|
38
|
+
const { schema, appConfigs } = await config.loadCliConfig({
|
|
39
|
+
args: config$1,
|
|
40
|
+
fromPackage: pkg,
|
|
41
|
+
mockEnv: lax,
|
|
42
|
+
fullVisibility: !frontend
|
|
43
|
+
});
|
|
44
|
+
const visibility = getVisibilityOption(frontend, withSecrets);
|
|
45
|
+
const data = serializeConfigData(appConfigs, schema, visibility);
|
|
46
|
+
if (format === "json") {
|
|
47
|
+
process.stdout.write(`${JSON.stringify(data, null, 2)}
|
|
48
|
+
`);
|
|
49
|
+
} else {
|
|
50
|
+
process.stdout.write(`${yaml.stringify(data)}
|
|
51
|
+
`);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
function getVisibilityOption(frontend, withSecrets) {
|
|
55
|
+
if (frontend && withSecrets) {
|
|
56
|
+
throw new Error("Not allowed to combine frontend and secret config");
|
|
57
|
+
}
|
|
58
|
+
if (frontend) {
|
|
59
|
+
return "frontend";
|
|
60
|
+
} else if (withSecrets) {
|
|
61
|
+
return "secret";
|
|
62
|
+
}
|
|
63
|
+
return "backend";
|
|
64
|
+
}
|
|
65
|
+
function serializeConfigData(appConfigs, schema, visibility) {
|
|
66
|
+
if (visibility === "frontend") {
|
|
67
|
+
const frontendConfigs = schema.process(appConfigs, {
|
|
68
|
+
visibility: ["frontend"]
|
|
69
|
+
});
|
|
70
|
+
return config$1.ConfigReader.fromConfigs(frontendConfigs).get();
|
|
71
|
+
} else if (visibility === "secret") {
|
|
72
|
+
return config$1.ConfigReader.fromConfigs(appConfigs).get();
|
|
73
|
+
}
|
|
74
|
+
const sanitizedConfigs = schema.process(appConfigs, {
|
|
75
|
+
valueTransform: (value, context) => context.visibility === "secret" ? "<secret>" : value
|
|
76
|
+
});
|
|
77
|
+
return config$1.ConfigReader.fromConfigs(sanitizedConfigs).get();
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
exports.default = print;
|
|
81
|
+
//# sourceMappingURL=print.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"print.cjs.js","sources":["../../src/commands/print.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 { cli } from 'cleye';\nimport { stringify as stringifyYaml } from 'yaml';\nimport { AppConfig, ConfigReader } from '@backstage/config';\nimport { loadCliConfig } from '../lib/config';\nimport { ConfigSchema, ConfigVisibility } from '@backstage/config-loader';\nimport type { CliCommandContext } from '@backstage/cli-node';\n\nexport default async ({ args, info }: CliCommandContext) => {\n const {\n flags: { config, lax, frontend, withSecrets, format, package: pkg },\n } = cli(\n {\n help: info,\n booleanFlagNegation: true,\n flags: {\n package: { type: String, description: 'Package to print config for' },\n lax: {\n type: Boolean,\n description: 'Do not require environment variables to be set',\n },\n frontend: { type: Boolean, description: 'Only print frontend config' },\n withSecrets: {\n type: Boolean,\n description: 'Include secrets in the output',\n },\n format: { type: String, description: 'Output format (yaml or json)' },\n config: {\n type: [String],\n description: 'Config files to load instead of app-config.yaml',\n },\n },\n },\n undefined,\n args,\n );\n\n const { schema, appConfigs } = await loadCliConfig({\n args: config,\n fromPackage: pkg,\n mockEnv: lax,\n fullVisibility: !frontend,\n });\n const visibility = getVisibilityOption(frontend, withSecrets);\n const data = serializeConfigData(appConfigs, schema, visibility);\n\n if (format === 'json') {\n process.stdout.write(`${JSON.stringify(data, null, 2)}\\n`);\n } else {\n process.stdout.write(`${stringifyYaml(data)}\\n`);\n }\n};\n\nfunction getVisibilityOption(\n frontend: boolean | undefined,\n withSecrets: boolean | undefined,\n): ConfigVisibility {\n if (frontend && withSecrets) {\n throw new Error('Not allowed to combine frontend and secret config');\n }\n if (frontend) {\n return 'frontend';\n } else if (withSecrets) {\n return 'secret';\n }\n return 'backend';\n}\n\nfunction serializeConfigData(\n appConfigs: AppConfig[],\n schema: ConfigSchema,\n visibility: ConfigVisibility,\n) {\n if (visibility === 'frontend') {\n const frontendConfigs = schema.process(appConfigs, {\n visibility: ['frontend'],\n });\n return ConfigReader.fromConfigs(frontendConfigs).get();\n } else if (visibility === 'secret') {\n return ConfigReader.fromConfigs(appConfigs).get();\n }\n\n const sanitizedConfigs = schema.process(appConfigs, {\n valueTransform: (value, context) =>\n context.visibility === 'secret' ? '<secret>' : value,\n });\n\n return ConfigReader.fromConfigs(sanitizedConfigs).get();\n}\n"],"names":["config","cli","loadCliConfig","stringifyYaml","ConfigReader"],"mappings":";;;;;;;;;AAuBA,YAAe,OAAO,EAAE,IAAA,EAAM,IAAA,EAAK,KAAyB;AAC1D,EAAA,MAAM;AAAA,IACJ,KAAA,EAAO,UAAEA,QAAA,EAAQ,GAAA,EAAK,UAAU,WAAA,EAAa,MAAA,EAAQ,SAAS,GAAA;AAAI,GACpE,GAAIC,SAAA;AAAA,IACF;AAAA,MACE,IAAA,EAAM,IAAA;AAAA,MACN,mBAAA,EAAqB,IAAA;AAAA,MACrB,KAAA,EAAO;AAAA,QACL,OAAA,EAAS,EAAE,IAAA,EAAM,MAAA,EAAQ,aAAa,6BAAA,EAA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B,IAAA,MAAM,IAAI,MAAM,mDAAmD,CAAA;AAAA,EACrE;AACA,EAAA,IAAI,QAAA,EAAU;AACZ,IAAA,OAAO,UAAA;AAAA,EACT,WAAW,WAAA,EAAa;AACtB,IAAA,OAAO,QAAA;AAAA,EACT;AACA,EAAA,OAAO,SAAA;AACT;AAEA,SAAS,mBAAA,CACP,UAAA,EACA,MAAA,EACA,UAAA,EACA;AACA,EAAA,IAAI,eAAe,UAAA,EAAY;AAC7B,IAAA,MAAM,eAAA,GAAkB,MAAA,CAAO,OAAA,CAAQ,UAAA,EAAY;AAAA,MACjD,UAAA,EAAY,CAAC,UAAU;AAAA,KACxB,CAAA;AACD,IAAA,OAAOC,qBAAA,CAAa,WAAA,CAAY,eAAe,CAAA,CAAE,GAAA,EAAI;AAAA,EACvD,CAAA,MAAA,IAAW,eAAe,QAAA,EAAU;AAClC,IAAA,OAAOA,qBAAA,CAAa,WAAA,CAAY,UAAU,CAAA,CAAE,GAAA,EAAI;AAAA,EAClD;AAEA,EAAA,MAAM,gBAAA,GAAmB,MAAA,CAAO,OAAA,CAAQ,UAAA,EAAY;AAAA,IAClD,gBAAgB,CAAC,KAAA,EAAO,YACtB,OAAA,CAAQ,UAAA,KAAe,WAAW,UAAA,GAAa;AAAA,GAClD,CAAA;AAED,EAAA,OAAOA,qBAAA,CAAa,WAAA,CAAY,gBAAgB,CAAA,CAAE,GAAA,EAAI;AACxD;;;;"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var cleye = require('cleye');
|
|
6
|
+
var yaml = require('yaml');
|
|
7
|
+
var config = require('../lib/config.cjs.js');
|
|
8
|
+
var configLoader = require('@backstage/config-loader');
|
|
9
|
+
|
|
10
|
+
var schema = async ({ args, info }) => {
|
|
11
|
+
const {
|
|
12
|
+
flags: { merge, format, package: pkg }
|
|
13
|
+
} = cleye.cli(
|
|
14
|
+
{
|
|
15
|
+
help: info,
|
|
16
|
+
booleanFlagNegation: true,
|
|
17
|
+
flags: {
|
|
18
|
+
package: { type: String, description: "Package to print schema for" },
|
|
19
|
+
format: { type: String, description: "Output format (yaml or json)" },
|
|
20
|
+
merge: {
|
|
21
|
+
type: Boolean,
|
|
22
|
+
description: "Merge all schemas into a single schema"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
void 0,
|
|
27
|
+
args
|
|
28
|
+
);
|
|
29
|
+
const { schema } = await config.loadCliConfig({
|
|
30
|
+
args: [],
|
|
31
|
+
fromPackage: pkg,
|
|
32
|
+
mockEnv: true
|
|
33
|
+
});
|
|
34
|
+
let configSchema;
|
|
35
|
+
if (merge) {
|
|
36
|
+
configSchema = configLoader.mergeConfigSchemas(
|
|
37
|
+
schema.serialize().schemas.map(
|
|
38
|
+
(_) => _.value
|
|
39
|
+
)
|
|
40
|
+
);
|
|
41
|
+
configSchema.title = "Application Configuration Schema";
|
|
42
|
+
configSchema.description = "This is the schema describing the structure of the app-config.yaml configuration file.";
|
|
43
|
+
} else {
|
|
44
|
+
configSchema = schema.serialize();
|
|
45
|
+
}
|
|
46
|
+
if (format === "json") {
|
|
47
|
+
process.stdout.write(`${JSON.stringify(configSchema, null, 2)}
|
|
48
|
+
`);
|
|
49
|
+
} else {
|
|
50
|
+
process.stdout.write(`${yaml.stringify(configSchema)}
|
|
51
|
+
`);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
exports.default = schema;
|
|
56
|
+
//# sourceMappingURL=schema.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.cjs.js","sources":["../../src/commands/schema.ts"],"sourcesContent":["/*\n * Copyright 2021 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 { cli } from 'cleye';\nimport { JSONSchema7 as JSONSchema } from 'json-schema';\nimport { stringify as stringifyYaml } from 'yaml';\nimport { loadCliConfig } from '../lib/config';\nimport { JsonObject } from '@backstage/types';\nimport { mergeConfigSchemas } from '@backstage/config-loader';\nimport type { CliCommandContext } from '@backstage/cli-node';\n\nexport default async ({ args, info }: CliCommandContext) => {\n const {\n flags: { merge, format, package: pkg },\n } = cli(\n {\n help: info,\n booleanFlagNegation: true,\n flags: {\n package: { type: String, description: 'Package to print schema for' },\n format: { type: String, description: 'Output format (yaml or json)' },\n merge: {\n type: Boolean,\n description: 'Merge all schemas into a single schema',\n },\n },\n },\n undefined,\n args,\n );\n\n const { schema } = await loadCliConfig({\n args: [],\n fromPackage: pkg,\n mockEnv: true,\n });\n\n let configSchema: JsonObject | JSONSchema;\n if (merge) {\n configSchema = mergeConfigSchemas(\n (schema.serialize().schemas as JsonObject[]).map(\n _ => _.value as JSONSchema,\n ),\n );\n configSchema.title = 'Application Configuration Schema';\n configSchema.description =\n 'This is the schema describing the structure of the app-config.yaml configuration file.';\n } else {\n configSchema = schema.serialize();\n }\n\n if (format === 'json') {\n process.stdout.write(`${JSON.stringify(configSchema, null, 2)}\\n`);\n } else {\n process.stdout.write(`${stringifyYaml(configSchema)}\\n`);\n }\n};\n"],"names":["cli","loadCliConfig","mergeConfigSchemas","stringifyYaml"],"mappings":";;;;;;;;;AAwBA,aAAe,OAAO,EAAE,IAAA,EAAM,IAAA,EAAK,KAAyB;AAC1D,EAAA,MAAM;AAAA,IACJ,KAAA,EAAO,EAAE,KAAA,EAAO,MAAA,EAAQ,SAAS,GAAA;AAAI,GACvC,GAAIA,SAAA;AAAA,IACF;AAAA,MACE,IAAA,EAAM,IAAA;AAAA,MACN,mB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object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var cleye = require('cleye');
|
|
6
|
+
var config = require('../lib/config.cjs.js');
|
|
7
|
+
|
|
8
|
+
var validate = async ({ args, info }) => {
|
|
9
|
+
const {
|
|
10
|
+
flags: { config: config$1, lax, frontend, deprecated, strict, package: pkg }
|
|
11
|
+
} = cleye.cli(
|
|
12
|
+
{
|
|
13
|
+
help: info,
|
|
14
|
+
booleanFlagNegation: true,
|
|
15
|
+
flags: {
|
|
16
|
+
package: {
|
|
17
|
+
type: String,
|
|
18
|
+
description: "Package to validate config for"
|
|
19
|
+
},
|
|
20
|
+
lax: {
|
|
21
|
+
type: Boolean,
|
|
22
|
+
description: "Do not require environment variables to be set"
|
|
23
|
+
},
|
|
24
|
+
frontend: {
|
|
25
|
+
type: Boolean,
|
|
26
|
+
description: "Only validate frontend config"
|
|
27
|
+
},
|
|
28
|
+
deprecated: { type: Boolean, description: "Output deprecated keys" },
|
|
29
|
+
strict: { type: Boolean, description: "Enable strict validation" },
|
|
30
|
+
config: {
|
|
31
|
+
type: [String],
|
|
32
|
+
description: "Config files to load instead of app-config.yaml"
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
void 0,
|
|
37
|
+
args
|
|
38
|
+
);
|
|
39
|
+
await config.loadCliConfig({
|
|
40
|
+
args: config$1,
|
|
41
|
+
fromPackage: pkg,
|
|
42
|
+
mockEnv: lax,
|
|
43
|
+
fullVisibility: !frontend,
|
|
44
|
+
withDeprecatedKeys: deprecated,
|
|
45
|
+
strict
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
exports.default = validate;
|
|
50
|
+
//# sourceMappingURL=validate.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.cjs.js","sources":["../../src/commands/validate.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 { cli } from 'cleye';\nimport { loadCliConfig } from '../lib/config';\nimport type { CliCommandContext } from '@backstage/cli-node';\n\nexport default async ({ args, info }: CliCommandContext) => {\n const {\n flags: { config, lax, frontend, deprecated, strict, package: pkg },\n } = cli(\n {\n help: info,\n booleanFlagNegation: true,\n flags: {\n package: {\n type: String,\n description: 'Package to validate config for',\n },\n lax: {\n type: Boolean,\n description: 'Do not require environment variables to be set',\n },\n frontend: {\n type: Boolean,\n description: 'Only validate frontend config',\n },\n deprecated: { type: Boolean, description: 'Output deprecated keys' },\n strict: { type: Boolean, description: 'Enable strict validation' },\n config: {\n type: [String],\n description: 'Config files to load instead of app-config.yaml',\n },\n },\n },\n undefined,\n args,\n );\n\n await loadCliConfig({\n args: config,\n fromPackage: pkg,\n mockEnv: lax,\n fullVisibility: !frontend,\n withDeprecatedKeys: deprecated,\n strict,\n });\n};\n"],"names":["config","cli","loadCliConfig"],"mappings":";;;;;;;AAoBA,eAAe,OAAO,EAAE,IAAA,EAAM,IAAA,EAAK,KAAyB;AAC1D,EAAA,MAAM;AAAA,IACJ,KAAA,EAAO,UAAEA,QAAA,EAAQ,GAAA,EAAK,UAAU,UAAA,EAAY,MAAA,EAAQ,SAAS,GAAA;AAAI,GACnE,GAAIC,SAAA;AAAA,IACF;AAAA,MACE,IAAA,EAAM,IAAA;AAAA,MACN,mBAAA,EAAqB,IAAA;AAAA,MACrB,KAAA,EAAO;AAAA,QACL,OAAA,EAAS;AAAA,UACP,IAAA,EAAM,MAAA;AAAA,UACN,WAAA,EAAa;AAAA,SACf;AAAA,QACA,GAAA,EAAK;AAAA,UACH,IAAA,EAAM,OAAA;AAAA,UACN,WAAA,EAAa;AAAA,SACf;AAAA,QACA,QAAA,EAAU;AAAA,UACR,IAAA,EAAM,OAAA;AAAA,UACN,WAAA,EAAa;AAAA,SACf;AAAA,QACA,UAAA,EAAY,EAAE,IAAA,EAAM,OAAA,EAAS,aAAa,wBAAA,EAAyB;AAAA,QACnE,MAAA,EAAQ,EAAE,IAAA,EAAM,OAAA,EAAS,aAAa,0BAAA,EAA2B;AAAA,QACjE,MAAA,EAAQ;AAAA,UACN,IAAA,EAAM,CAAC,MAAM,CAAA;AAAA,UACb,WAAA,EAAa;AAAA;AACf;AACF,KACF;AAAA,IACA,MAAA;AAAA,IACA;AAAA,GACF;AAEA,EAAA,MAAMC,oBAAA,CAAc;AAAA,IAClB,IAAA,EAAMF,QAAA;AAAA,IACN,WAAA,EAAa,GAAA;AAAA,IACb,OAAA,EAAS,GAAA;AAAA,IACT,gBAAgB,CAAC,QAAA;AAAA,IACjB,kBAAA,EAAoB,UAAA;AAAA,IACpB;AAAA,GACD,CAAA;AACH,CAAA;;;;"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var cliNode = require('@backstage/cli-node');
|
|
6
|
+
var _package = require('./package.json.cjs.js');
|
|
7
|
+
|
|
8
|
+
var index = cliNode.createCliModule({
|
|
9
|
+
packageJson: _package.default,
|
|
10
|
+
init: async (reg) => {
|
|
11
|
+
reg.addCommand({
|
|
12
|
+
path: ["config:docs"],
|
|
13
|
+
description: "Browse the configuration reference documentation",
|
|
14
|
+
execute: { loader: () => import('./commands/docs.cjs.js') }
|
|
15
|
+
});
|
|
16
|
+
reg.addCommand({
|
|
17
|
+
path: ["config", "docs"],
|
|
18
|
+
description: "Browse the configuration reference documentation",
|
|
19
|
+
execute: { loader: () => import('./commands/docs.cjs.js') }
|
|
20
|
+
});
|
|
21
|
+
reg.addCommand({
|
|
22
|
+
path: ["config:print"],
|
|
23
|
+
description: "Print the app configuration for the current package",
|
|
24
|
+
execute: { loader: () => import('./commands/print.cjs.js') }
|
|
25
|
+
});
|
|
26
|
+
reg.addCommand({
|
|
27
|
+
path: ["config:check"],
|
|
28
|
+
description: "Validate that the given configuration loads and matches schema",
|
|
29
|
+
execute: { loader: () => import('./commands/validate.cjs.js') }
|
|
30
|
+
});
|
|
31
|
+
reg.addCommand({
|
|
32
|
+
path: ["config:schema"],
|
|
33
|
+
description: "Print the JSON schema for the given configuration",
|
|
34
|
+
execute: { loader: () => import('./commands/schema.cjs.js') }
|
|
35
|
+
});
|
|
36
|
+
reg.addCommand({
|
|
37
|
+
path: ["config", "schema"],
|
|
38
|
+
description: "Print the JSON schema for the given configuration",
|
|
39
|
+
execute: { loader: () => import('./commands/schema.cjs.js') }
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
exports.default = index;
|
|
45
|
+
//# sourceMappingURL=index.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":["../src/index.ts"],"sourcesContent":["/*\n * Copyright 2024 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 */\nimport { createCliModule } from '@backstage/cli-node';\nimport packageJson from '../package.json';\n\nexport default createCliModule({\n packageJson,\n init: async reg => {\n reg.addCommand({\n path: ['config:docs'],\n description: 'Browse the configuration reference documentation',\n execute: { loader: () => import('./commands/docs') },\n });\n reg.addCommand({\n path: ['config', 'docs'],\n description: 'Browse the configuration reference documentation',\n execute: { loader: () => import('./commands/docs') },\n });\n reg.addCommand({\n path: ['config:print'],\n description: 'Print the app configuration for the current package',\n execute: { loader: () => import('./commands/print') },\n });\n reg.addCommand({\n path: ['config:check'],\n description:\n 'Validate that the given configuration loads and matches schema',\n execute: { loader: () => import('./commands/validate') },\n });\n reg.addCommand({\n path: ['config:schema'],\n description: 'Print the JSON schema for the given configuration',\n execute: { loader: () => import('./commands/schema') },\n });\n reg.addCommand({\n path: ['config', 'schema'],\n description: 'Print the JSON schema for the given configuration',\n execute: { loader: () => import('./commands/schema') },\n });\n },\n});\n"],"names":["createCliModule","packageJson"],"mappings":";;;;;;;AAkBA,YAAeA,uBAAA,CAAgB;AAAA,eAC7BC,gBAAA;AAAA,EACA,IAAA,EAAM,OAAM,GAAA,KAAO;AACjB,IAAA,GAAA,CAAI,UAAA,CAAW;AAAA,MACb,IAAA,EAAM,CAAC,aAAa,CAAA;AAAA,MACpB,WAAA,EAAa,kDAAA;AAAA,MACb,SAAS,EAAE,MAAA,EAAQ,MAAM,OAAO,wBAAiB,CAAA;AAAE,KACpD,CAAA;AACD,IAAA,GAAA,CAAI,UAAA,CAAW;AAAA,MACb,IAAA,EAAM,CAAC,QAAA,EAAU,MAAM,CAAA;AAAA,MACvB,WAAA,EAAa,kDAAA;AAAA,MACb,SAAS,EAAE,MAAA,EAAQ,MAAM,OAAO,wBAAiB,CAAA;AAAE,KACpD,CAAA;AACD,IAAA,GAAA,CAAI,UAAA,CAAW;AAAA,MACb,IAAA,EAAM,CAAC,cAAc,CAAA;AAAA,MACrB,WAAA,EAAa,qDAAA;AAAA,MACb,SAAS,EAAE,MAAA,EAAQ,MAAM,OAAO,yBAAkB,CAAA;AAAE,KACrD,CAAA;AACD,IAAA,GAAA,CAAI,UAAA,CAAW;AAAA,MACb,IAAA,EAAM,CAAC,cAAc,CAAA;AAAA,MACrB,WAAA,EACE,gEAAA;AAAA,MACF,SAAS,EAAE,MAAA,EAAQ,MAAM,OAAO,4BAAqB,CAAA;AAAE,KACxD,CAAA;AACD,IAAA,GAAA,CAAI,UAAA,CAAW;AAAA,MACb,IAAA,EAAM,CAAC,eAAe,CAAA;AAAA,MACtB,WAAA,EAAa,mDAAA;AAAA,MACb,SAAS,EAAE,MAAA,EAAQ,MAAM,OAAO,0BAAmB,CAAA;AAAE,KACtD,CAAA;AACD,IAAA,GAAA,CAAI,UAAA,CAAW;AAAA,MACb,IAAA,EAAM,CAAC,QAAA,EAAU,QAAQ,CAAA;AAAA,MACzB,WAAA,EAAa,mDAAA;AAAA,MACb,SAAS,EAAE,MAAA,EAAQ,MAAM,OAAO,0BAAmB,CAAA;AAAE,KACtD,CAAA;AAAA,EACH;AACF,CAAC,CAAA;;;;"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var configLoader = require('@backstage/config-loader');
|
|
4
|
+
var config = require('@backstage/config');
|
|
5
|
+
var cliCommon = require('@backstage/cli-common');
|
|
6
|
+
var getPackages = require('@manypkg/get-packages');
|
|
7
|
+
var cliNode = require('@backstage/cli-node');
|
|
8
|
+
var node_path = require('node:path');
|
|
9
|
+
|
|
10
|
+
async function loadCliConfig(options) {
|
|
11
|
+
const targetDir = options.targetDir ?? cliCommon.targetPaths.dir;
|
|
12
|
+
const { packages } = await getPackages.getPackages(targetDir);
|
|
13
|
+
let localPackageNames;
|
|
14
|
+
if (options.fromPackage) {
|
|
15
|
+
if (packages.length) {
|
|
16
|
+
const graph = cliNode.PackageGraph.fromPackages(packages);
|
|
17
|
+
localPackageNames = Array.from(
|
|
18
|
+
graph.collectPackageNames([options.fromPackage], (node) => {
|
|
19
|
+
if (node.name === "@backstage/cli") {
|
|
20
|
+
return void 0;
|
|
21
|
+
}
|
|
22
|
+
return node.localDependencies.keys();
|
|
23
|
+
})
|
|
24
|
+
);
|
|
25
|
+
} else {
|
|
26
|
+
localPackageNames = [options.fromPackage];
|
|
27
|
+
}
|
|
28
|
+
} else {
|
|
29
|
+
localPackageNames = packages.map((p) => p.packageJson.name);
|
|
30
|
+
}
|
|
31
|
+
const schema = await configLoader.loadConfigSchema({
|
|
32
|
+
dependencies: localPackageNames,
|
|
33
|
+
// Include the package.json in the project root if it exists
|
|
34
|
+
packagePaths: [cliCommon.targetPaths.resolveRoot("package.json")],
|
|
35
|
+
noUndeclaredProperties: options.strict
|
|
36
|
+
});
|
|
37
|
+
const source = configLoader.ConfigSources.default({
|
|
38
|
+
allowMissingDefaultConfig: true,
|
|
39
|
+
substitutionFunc: options.mockEnv ? async (name) => process.env[name] || "x" : void 0,
|
|
40
|
+
rootDir: cliCommon.targetPaths.rootDir,
|
|
41
|
+
argv: options.args.flatMap((t) => ["--config", node_path.resolve(targetDir, t)])
|
|
42
|
+
});
|
|
43
|
+
const appConfigs = await new Promise((resolve, reject) => {
|
|
44
|
+
async function readConfig() {
|
|
45
|
+
let loaded = false;
|
|
46
|
+
try {
|
|
47
|
+
const abortController = new AbortController();
|
|
48
|
+
for await (const { configs } of source.readConfigData({
|
|
49
|
+
signal: abortController.signal
|
|
50
|
+
})) {
|
|
51
|
+
resolve(configs);
|
|
52
|
+
loaded = true;
|
|
53
|
+
abortController.abort();
|
|
54
|
+
}
|
|
55
|
+
} catch (error) {
|
|
56
|
+
if (!loaded) {
|
|
57
|
+
reject(error);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
readConfig();
|
|
62
|
+
});
|
|
63
|
+
const configurationLoadedMessage = appConfigs.length ? `Loaded config from ${appConfigs.map((c) => c.context).join(", ")}` : `No configuration files found, running without config`;
|
|
64
|
+
process.stderr.write(`${configurationLoadedMessage}
|
|
65
|
+
`);
|
|
66
|
+
try {
|
|
67
|
+
const frontendAppConfigs = schema.process(appConfigs, {
|
|
68
|
+
visibility: options.fullVisibility ? ["frontend", "backend", "secret"] : ["frontend"],
|
|
69
|
+
withDeprecatedKeys: options.withDeprecatedKeys,
|
|
70
|
+
ignoreSchemaErrors: !options.strict
|
|
71
|
+
});
|
|
72
|
+
const frontendConfig = config.ConfigReader.fromConfigs(frontendAppConfigs);
|
|
73
|
+
const fullConfig = config.ConfigReader.fromConfigs(appConfigs);
|
|
74
|
+
return {
|
|
75
|
+
schema,
|
|
76
|
+
appConfigs,
|
|
77
|
+
frontendConfig,
|
|
78
|
+
frontendAppConfigs,
|
|
79
|
+
fullConfig
|
|
80
|
+
};
|
|
81
|
+
} catch (error) {
|
|
82
|
+
const maybeSchemaError = error;
|
|
83
|
+
if (maybeSchemaError.messages) {
|
|
84
|
+
const messages = maybeSchemaError.messages.join("\n ");
|
|
85
|
+
throw new Error(`Configuration does not match schema
|
|
86
|
+
|
|
87
|
+
${messages}`);
|
|
88
|
+
}
|
|
89
|
+
throw error;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
exports.loadCliConfig = loadCliConfig;
|
|
94
|
+
//# sourceMappingURL=config.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.cjs.js","sources":["../../src/lib/config.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 { ConfigSources, loadConfigSchema } from '@backstage/config-loader';\nimport { AppConfig, ConfigReader } from '@backstage/config';\nimport { targetPaths } from '@backstage/cli-common';\n\nimport { getPackages } from '@manypkg/get-packages';\nimport { PackageGraph } from '@backstage/cli-node';\nimport { resolve as resolvePath } from 'node:path';\n\ntype Options = {\n args: string[];\n targetDir?: string;\n fromPackage?: string;\n mockEnv?: boolean;\n withDeprecatedKeys?: boolean;\n fullVisibility?: boolean;\n strict?: boolean;\n};\n\nexport async function loadCliConfig(options: Options) {\n const targetDir = options.targetDir ?? targetPaths.dir;\n\n // Consider all packages in the monorepo when loading in config\n const { packages } = await getPackages(targetDir);\n\n let localPackageNames;\n if (options.fromPackage) {\n if (packages.length) {\n const graph = PackageGraph.fromPackages(packages);\n localPackageNames = Array.from(\n graph.collectPackageNames([options.fromPackage], node => {\n // Workaround for Backstage main repo only, since the CLI has some artificial devDependencies\n if (node.name === '@backstage/cli') {\n return undefined;\n }\n return node.localDependencies.keys();\n }),\n );\n } else {\n // No packages: it means that it's not a monorepo (e.g. standalone plugin)\n localPackageNames = [options.fromPackage];\n }\n } else {\n localPackageNames = packages.map(p => p.packageJson.name);\n }\n\n const schema = await loadConfigSchema({\n dependencies: localPackageNames,\n // Include the package.json in the project root if it exists\n packagePaths: [targetPaths.resolveRoot('package.json')],\n noUndeclaredProperties: options.strict,\n });\n\n const source = ConfigSources.default({\n allowMissingDefaultConfig: true,\n substitutionFunc: options.mockEnv\n ? async name => process.env[name] || 'x'\n : undefined,\n rootDir: targetPaths.rootDir,\n argv: options.args.flatMap(t => ['--config', resolvePath(targetDir, t)]),\n });\n\n const appConfigs = await new Promise<AppConfig[]>((resolve, reject) => {\n async function readConfig() {\n let loaded = false;\n try {\n const abortController = new AbortController();\n for await (const { configs } of source.readConfigData({\n signal: abortController.signal,\n })) {\n resolve(configs);\n loaded = true;\n abortController.abort();\n }\n } catch (error) {\n if (!loaded) {\n reject(error);\n }\n }\n }\n readConfig();\n });\n\n const configurationLoadedMessage = appConfigs.length\n ? `Loaded config from ${appConfigs.map(c => c.context).join(', ')}`\n : `No configuration files found, running without config`;\n\n // printing to stderr to not clobber stdout in case the cli command\n // outputs structured data (e.g. as config:schema does)\n process.stderr.write(`${configurationLoadedMessage}\\n`);\n\n try {\n const frontendAppConfigs = schema.process(appConfigs, {\n visibility: options.fullVisibility\n ? ['frontend', 'backend', 'secret']\n : ['frontend'],\n withDeprecatedKeys: options.withDeprecatedKeys,\n ignoreSchemaErrors: !options.strict,\n });\n const frontendConfig = ConfigReader.fromConfigs(frontendAppConfigs);\n\n const fullConfig = ConfigReader.fromConfigs(appConfigs);\n\n return {\n schema,\n appConfigs,\n frontendConfig,\n frontendAppConfigs,\n fullConfig,\n };\n } catch (error) {\n const maybeSchemaError = error as Error & { messages?: string[] };\n if (maybeSchemaError.messages) {\n const messages = maybeSchemaError.messages.join('\\n ');\n throw new Error(`Configuration does not match schema\\n\\n ${messages}`);\n }\n throw error;\n }\n}\n"],"names":["targetPaths","getPackages","PackageGraph","loadConfigSchema","ConfigSources","resolvePath","ConfigReader"],"mappings":";;;;;;;;;AAkCA,eAAsB,cAAc,OAAA,EAAkB;AACpD,EAAA,MAAM,SAAA,GAAY,OAAA,CAAQ,SAAA,IAAaA,qBAAA,CAAY,GAAA;AAGnD,EAAA,MAAM,EAAE,QAAA,EAAS,GAAI,MAAMC,wBAAY,SAAS,CAAA;AAEhD,EAAA,IAAI,iBAAA;AACJ,EAAA,IAAI,QAAQ,WAAA,EAAa;AACvB,IAAA,IAAI,SAAS,MAAA,EAAQ;AACnB,MAAA,MAAM,KAAA,GAAQC,oBAAA,CAAa,YAAA,CAAa,QAAQ,CAAA;AAChD,MAAA,iBAAA,GAAoB,KAAA,CAAM,IAAA;AAAA,QACxB,MAAM,mBAAA,CAAoB,CAAC,OAAA,CAAQ,WAAW,GAAG,CAAA,IAAA,KAAQ;AAEvD,UAAA,IAAI,IAAA,CAAK,SAAS,gBAAA,EAAkB;AAClC,YAAA,OAAO,MAAA;AAAA,UACT;AACA,UAAA,OAAO,IAAA,CAAK,kBAAkB,IAAA,EAAK;AAAA,QACrC,CAAC;AAAA,OACH;AAAA,IACF,CAAA,MAAO;AAEL,MAAA,iBAAA,GAAoB,CAAC,QAAQ,WAAW,CAAA;AAAA,IAC1C;AAAA,EACF,CAAA,MAAO;AACL,IAAA,iBAAA,GAAoB,QAAA,CAAS,GAAA,CAAI,CAAA,CAAA,KAAK,CAAA,CAAE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@@ -0,0 +1,89 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var name = "@backstage/cli-module-config";
|
|
6
|
+
var version = "0.0.0-nightly-20260317031259";
|
|
7
|
+
var description = "CLI module for Backstage CLI";
|
|
8
|
+
var backstage = {
|
|
9
|
+
role: "cli-module"
|
|
10
|
+
};
|
|
11
|
+
var publishConfig = {
|
|
12
|
+
access: "public",
|
|
13
|
+
main: "dist/index.cjs.js",
|
|
14
|
+
types: "dist/index.d.ts"
|
|
15
|
+
};
|
|
16
|
+
var homepage = "https://backstage.io";
|
|
17
|
+
var repository = {
|
|
18
|
+
type: "git",
|
|
19
|
+
url: "https://github.com/backstage/backstage",
|
|
20
|
+
directory: "packages/cli-module-config"
|
|
21
|
+
};
|
|
22
|
+
var license = "Apache-2.0";
|
|
23
|
+
var main = "src/index.ts";
|
|
24
|
+
var types = "src/index.ts";
|
|
25
|
+
var files = [
|
|
26
|
+
"dist",
|
|
27
|
+
"bin"
|
|
28
|
+
];
|
|
29
|
+
var scripts = {
|
|
30
|
+
build: "backstage-cli package build",
|
|
31
|
+
clean: "backstage-cli package clean",
|
|
32
|
+
lint: "backstage-cli package lint",
|
|
33
|
+
prepack: "backstage-cli package prepack",
|
|
34
|
+
postpack: "backstage-cli package postpack",
|
|
35
|
+
test: "backstage-cli package test"
|
|
36
|
+
};
|
|
37
|
+
var dependencies = {
|
|
38
|
+
"@backstage/cli-common": "workspace:*",
|
|
39
|
+
"@backstage/cli-node": "workspace:*",
|
|
40
|
+
"@backstage/config": "workspace:*",
|
|
41
|
+
"@backstage/config-loader": "workspace:*",
|
|
42
|
+
"@backstage/types": "workspace:*",
|
|
43
|
+
"@manypkg/get-packages": "^1.1.3",
|
|
44
|
+
chalk: "^4.0.0",
|
|
45
|
+
cleye: "^2.3.0",
|
|
46
|
+
"json-schema": "^0.4.0",
|
|
47
|
+
"react-dev-utils": "^12.0.0-next.60",
|
|
48
|
+
yaml: "^2.0.0"
|
|
49
|
+
};
|
|
50
|
+
var devDependencies = {
|
|
51
|
+
"@backstage/cli": "workspace:*",
|
|
52
|
+
"@types/json-schema": "^7.0.6"
|
|
53
|
+
};
|
|
54
|
+
var bin = "bin/backstage-cli-module-config";
|
|
55
|
+
var packageJson = {
|
|
56
|
+
name: name,
|
|
57
|
+
version: version,
|
|
58
|
+
description: description,
|
|
59
|
+
backstage: backstage,
|
|
60
|
+
publishConfig: publishConfig,
|
|
61
|
+
homepage: homepage,
|
|
62
|
+
repository: repository,
|
|
63
|
+
license: license,
|
|
64
|
+
main: main,
|
|
65
|
+
types: types,
|
|
66
|
+
files: files,
|
|
67
|
+
scripts: scripts,
|
|
68
|
+
dependencies: dependencies,
|
|
69
|
+
devDependencies: devDependencies,
|
|
70
|
+
bin: bin
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
exports.backstage = backstage;
|
|
74
|
+
exports.bin = bin;
|
|
75
|
+
exports.default = packageJson;
|
|
76
|
+
exports.dependencies = dependencies;
|
|
77
|
+
exports.description = description;
|
|
78
|
+
exports.devDependencies = devDependencies;
|
|
79
|
+
exports.files = files;
|
|
80
|
+
exports.homepage = homepage;
|
|
81
|
+
exports.license = license;
|
|
82
|
+
exports.main = main;
|
|
83
|
+
exports.name = name;
|
|
84
|
+
exports.publishConfig = publishConfig;
|
|
85
|
+
exports.repository = repository;
|
|
86
|
+
exports.scripts = scripts;
|
|
87
|
+
exports.types = types;
|
|
88
|
+
exports.version = version;
|
|
89
|
+
//# sourceMappingURL=package.json.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package.json.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@backstage/cli-module-config",
|
|
3
|
+
"version": "0.0.0-nightly-20260317031259",
|
|
4
|
+
"description": "CLI module for Backstage CLI",
|
|
5
|
+
"backstage": {
|
|
6
|
+
"role": "cli-module"
|
|
7
|
+
},
|
|
8
|
+
"publishConfig": {
|
|
9
|
+
"access": "public",
|
|
10
|
+
"main": "dist/index.cjs.js",
|
|
11
|
+
"types": "dist/index.d.ts"
|
|
12
|
+
},
|
|
13
|
+
"homepage": "https://backstage.io",
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "https://github.com/backstage/backstage",
|
|
17
|
+
"directory": "packages/cli-module-config"
|
|
18
|
+
},
|
|
19
|
+
"license": "Apache-2.0",
|
|
20
|
+
"main": "dist/index.cjs.js",
|
|
21
|
+
"types": "dist/index.d.ts",
|
|
22
|
+
"files": [
|
|
23
|
+
"dist",
|
|
24
|
+
"bin"
|
|
25
|
+
],
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "backstage-cli package build",
|
|
28
|
+
"clean": "backstage-cli package clean",
|
|
29
|
+
"lint": "backstage-cli package lint",
|
|
30
|
+
"prepack": "backstage-cli package prepack",
|
|
31
|
+
"postpack": "backstage-cli package postpack",
|
|
32
|
+
"test": "backstage-cli package test"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@backstage/cli-common": "0.0.0-nightly-20260317031259",
|
|
36
|
+
"@backstage/cli-node": "0.0.0-nightly-20260317031259",
|
|
37
|
+
"@backstage/config": "1.3.6",
|
|
38
|
+
"@backstage/config-loader": "0.0.0-nightly-20260317031259",
|
|
39
|
+
"@backstage/types": "1.2.2",
|
|
40
|
+
"@manypkg/get-packages": "^1.1.3",
|
|
41
|
+
"chalk": "^4.0.0",
|
|
42
|
+
"cleye": "^2.3.0",
|
|
43
|
+
"json-schema": "^0.4.0",
|
|
44
|
+
"react-dev-utils": "^12.0.0-next.60",
|
|
45
|
+
"yaml": "^2.0.0"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@backstage/cli": "0.0.0-nightly-20260317031259",
|
|
49
|
+
"@types/json-schema": "^7.0.6"
|
|
50
|
+
},
|
|
51
|
+
"bin": "bin/backstage-cli-module-config",
|
|
52
|
+
"typesVersions": {
|
|
53
|
+
"*": {
|
|
54
|
+
"package.json": [
|
|
55
|
+
"package.json"
|
|
56
|
+
]
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|