@backstage/cli-module-build 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 +18 -0
- package/README.md +23 -0
- package/bin/backstage-cli-module-build +32 -0
- package/config/webpack-public-path.js +31 -0
- package/dist/commands/buildWorkspace.cjs.js +53 -0
- package/dist/commands/buildWorkspace.cjs.js.map +1 -0
- package/dist/commands/package/build/command.cjs.js +136 -0
- package/dist/commands/package/build/command.cjs.js.map +1 -0
- package/dist/commands/package/build/index.cjs.js +10 -0
- package/dist/commands/package/build/index.cjs.js.map +1 -0
- package/dist/commands/package/bundle/command.cjs.js +691 -0
- package/dist/commands/package/bundle/command.cjs.js.map +1 -0
- package/dist/commands/package/bundle/index.cjs.js +10 -0
- package/dist/commands/package/bundle/index.cjs.js.map +1 -0
- package/dist/commands/package/clean.cjs.js +21 -0
- package/dist/commands/package/clean.cjs.js.map +1 -0
- package/dist/commands/package/postpack.cjs.js +15 -0
- package/dist/commands/package/postpack.cjs.js.map +1 -0
- package/dist/commands/package/prepack.cjs.js +29 -0
- package/dist/commands/package/prepack.cjs.js.map +1 -0
- package/dist/commands/package/start/command.cjs.js +80 -0
- package/dist/commands/package/start/command.cjs.js.map +1 -0
- package/dist/commands/package/start/index.cjs.js +10 -0
- package/dist/commands/package/start/index.cjs.js.map +1 -0
- package/dist/commands/package/start/resolveLinkedWorkspace.cjs.js +34 -0
- package/dist/commands/package/start/resolveLinkedWorkspace.cjs.js.map +1 -0
- package/dist/commands/package/start/startBackend.cjs.js +46 -0
- package/dist/commands/package/start/startBackend.cjs.js.map +1 -0
- package/dist/commands/package/start/startFrontend.cjs.js +49 -0
- package/dist/commands/package/start/startFrontend.cjs.js.map +1 -0
- package/dist/commands/package/start/startPackage.cjs.js +53 -0
- package/dist/commands/package/start/startPackage.cjs.js.map +1 -0
- package/dist/commands/repo/build.cjs.js +149 -0
- package/dist/commands/repo/build.cjs.js.map +1 -0
- package/dist/commands/repo/clean.cjs.js +41 -0
- package/dist/commands/repo/clean.cjs.js.map +1 -0
- package/dist/commands/repo/start.cjs.js +199 -0
- package/dist/commands/repo/start.cjs.js.map +1 -0
- package/dist/index.cjs.js +74 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/lib/buildBackend.cjs.js +81 -0
- package/dist/lib/buildBackend.cjs.js.map +1 -0
- package/dist/lib/buildFrontend.cjs.js +49 -0
- package/dist/lib/buildFrontend.cjs.js.map +1 -0
- package/dist/lib/builder/config.cjs.js +257 -0
- package/dist/lib/builder/config.cjs.js.map +1 -0
- package/dist/lib/builder/packager.cjs.js +131 -0
- package/dist/lib/builder/packager.cjs.js.map +1 -0
- package/dist/lib/builder/plugins.cjs.js +125 -0
- package/dist/lib/builder/plugins.cjs.js.map +1 -0
- package/dist/lib/builder/types.cjs.js +10 -0
- package/dist/lib/builder/types.cjs.js.map +1 -0
- package/dist/lib/bundler/ConfigInjectingHtmlWebpackPlugin.cjs.js +43 -0
- package/dist/lib/bundler/ConfigInjectingHtmlWebpackPlugin.cjs.js.map +1 -0
- package/dist/lib/bundler/bundle.cjs.js +189 -0
- package/dist/lib/bundler/bundle.cjs.js.map +1 -0
- package/dist/lib/bundler/config.cjs.js +309 -0
- package/dist/lib/bundler/config.cjs.js.map +1 -0
- package/dist/lib/bundler/hasReactDomClient.cjs.js +17 -0
- package/dist/lib/bundler/hasReactDomClient.cjs.js.map +1 -0
- package/dist/lib/bundler/linkWorkspaces.cjs.js +34 -0
- package/dist/lib/bundler/linkWorkspaces.cjs.js.map +1 -0
- package/dist/lib/bundler/moduleFederation.cjs.js +135 -0
- package/dist/lib/bundler/moduleFederation.cjs.js.map +1 -0
- package/dist/lib/bundler/optimization.cjs.js +68 -0
- package/dist/lib/bundler/optimization.cjs.js.map +1 -0
- package/dist/lib/bundler/packageDetection.cjs.js +124 -0
- package/dist/lib/bundler/packageDetection.cjs.js.map +1 -0
- package/dist/lib/bundler/paths.cjs.js +62 -0
- package/dist/lib/bundler/paths.cjs.js.map +1 -0
- package/dist/lib/bundler/server.cjs.js +231 -0
- package/dist/lib/bundler/server.cjs.js.map +1 -0
- package/dist/lib/bundler/transforms.cjs.js +145 -0
- package/dist/lib/bundler/transforms.cjs.js.map +1 -0
- package/dist/lib/config.cjs.js +94 -0
- package/dist/lib/config.cjs.js.map +1 -0
- package/dist/lib/entryPoints.cjs.js +49 -0
- package/dist/lib/entryPoints.cjs.js.map +1 -0
- package/dist/lib/ipc/IpcServer.cjs.js +60 -0
- package/dist/lib/ipc/IpcServer.cjs.js.map +1 -0
- package/dist/lib/ipc/ServerDataStore.cjs.js +36 -0
- package/dist/lib/ipc/ServerDataStore.cjs.js.map +1 -0
- package/dist/lib/optionsParser.cjs.js +22 -0
- package/dist/lib/optionsParser.cjs.js.map +1 -0
- package/dist/lib/packager/createDistWorkspace.cjs.js +252 -0
- package/dist/lib/packager/createDistWorkspace.cjs.js.map +1 -0
- package/dist/lib/packager/productionPack.cjs.js +160 -0
- package/dist/lib/packager/productionPack.cjs.js.map +1 -0
- package/dist/lib/publishing.cjs.js +40 -0
- package/dist/lib/publishing.cjs.js.map +1 -0
- package/dist/lib/role.cjs.js +24 -0
- package/dist/lib/role.cjs.js.map +1 -0
- package/dist/lib/runner/runBackend.cjs.js +136 -0
- package/dist/lib/runner/runBackend.cjs.js.map +1 -0
- package/dist/lib/typeDistProject.cjs.js +89 -0
- package/dist/lib/typeDistProject.cjs.js.map +1 -0
- package/dist/lib/urls.cjs.js +13 -0
- package/dist/lib/urls.cjs.js.map +1 -0
- package/dist/package.json.cjs.js +143 -0
- package/dist/package.json.cjs.js.map +1 -0
- package/package.json +113 -0
- package/templates/serve_index.html +27 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# @backstage/cli-module-build
|
|
2
|
+
|
|
3
|
+
## 0.0.0-nightly-20260317031259
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 62d0849: Added `package bundle` command to create self-contained plugin bundles for dynamic loading, to be used by the `backend-dynamic-feature-service`. Supports backend and frontend plugins, with optional `--pre-packed-dir` for batch bundling from a pre-built workspace.
|
|
8
|
+
- 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.
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- Updated dependencies
|
|
13
|
+
- @backstage/cli-node@0.0.0-nightly-20260317031259
|
|
14
|
+
- @backstage/cli-common@0.0.0-nightly-20260317031259
|
|
15
|
+
- @backstage/module-federation-common@0.0.0-nightly-20260317031259
|
|
16
|
+
- @backstage/config-loader@0.0.0-nightly-20260317031259
|
|
17
|
+
- @backstage/config@1.3.6
|
|
18
|
+
- @backstage/errors@1.2.7
|
package/README.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# @backstage/cli-module-build
|
|
2
|
+
|
|
3
|
+
CLI module that provides build, start, and packaging commands for the Backstage CLI.
|
|
4
|
+
|
|
5
|
+
## Commands
|
|
6
|
+
|
|
7
|
+
| Command | Description |
|
|
8
|
+
| :----------------- | :------------------------------------------------------------------------ |
|
|
9
|
+
| `package build` | Build a package for production deployment or publishing |
|
|
10
|
+
| `package start` | Start a package for local development |
|
|
11
|
+
| `package clean` | Delete cache directories |
|
|
12
|
+
| `package prepack` | Prepares a package for packaging before publishing |
|
|
13
|
+
| `package postpack` | Restores the changes made by the prepack command |
|
|
14
|
+
| `repo build` | Build packages in the project, excluding bundled app and backend packages |
|
|
15
|
+
| `repo start` | Starts packages in the repo for local development |
|
|
16
|
+
| `repo clean` | Delete cache and output directories |
|
|
17
|
+
| `build-workspace` | Builds a temporary dist workspace from the provided packages |
|
|
18
|
+
|
|
19
|
+
## Documentation
|
|
20
|
+
|
|
21
|
+
- [Backstage Readme](https://github.com/backstage/backstage/blob/master/README.md)
|
|
22
|
+
- [Backstage Documentation](https://backstage.io/docs)
|
|
23
|
+
- [Build System](https://backstage.io/docs/tooling/cli/build-system)
|
|
@@ -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,31 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2024 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
|
+
// This script is used to pick up and set the public path of the Webpack bundle
|
|
18
|
+
// at runtime. The meta tag is injected by the app build, but only present in
|
|
19
|
+
// the `index.html.tmpl` file. The runtime value of the meta tag is populated by
|
|
20
|
+
// the app backend, when it templates the final `index.html` file.
|
|
21
|
+
//
|
|
22
|
+
// This is needed for additional chunks to use the correct public path, and it
|
|
23
|
+
// is not possible to set the `__webpack_public_path__` variable outside of the
|
|
24
|
+
// build itself. The Webpack output also does not read any <base> tags or
|
|
25
|
+
// similar, this seems to be the only way to dynamically configure the public
|
|
26
|
+
// path at runtime.
|
|
27
|
+
const el = document.querySelector('meta[name="backstage-public-path"]');
|
|
28
|
+
const path = el?.getAttribute('content');
|
|
29
|
+
if (path) {
|
|
30
|
+
__webpack_public_path__ = path;
|
|
31
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var fs = require('fs-extra');
|
|
6
|
+
var cleye = require('cleye');
|
|
7
|
+
var createDistWorkspace = require('../lib/packager/createDistWorkspace.cjs.js');
|
|
8
|
+
|
|
9
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
10
|
+
|
|
11
|
+
var fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
|
|
12
|
+
|
|
13
|
+
var buildWorkspace = async ({ args, info }) => {
|
|
14
|
+
const normalizedArgs = args.map((a) => {
|
|
15
|
+
if (a === "--alwaysYarnPack") {
|
|
16
|
+
return "--always-pack";
|
|
17
|
+
}
|
|
18
|
+
if (a.startsWith("--alwaysYarnPack=")) {
|
|
19
|
+
return `--always-pack${a.substring("--alwaysYarnPack".length)}`;
|
|
20
|
+
}
|
|
21
|
+
return a;
|
|
22
|
+
});
|
|
23
|
+
const {
|
|
24
|
+
flags: { alwaysPack },
|
|
25
|
+
_: positionals
|
|
26
|
+
} = cleye.cli(
|
|
27
|
+
{
|
|
28
|
+
help: { ...info, usage: `${info.usage} <workspace-dir> [packages...]` },
|
|
29
|
+
booleanFlagNegation: true,
|
|
30
|
+
parameters: ["<workspace-dir>", "[packages...]"],
|
|
31
|
+
flags: {
|
|
32
|
+
alwaysPack: {
|
|
33
|
+
type: Boolean,
|
|
34
|
+
description: "Force workspace output to be a result of running `yarn pack` on each package (warning: very slow)"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
void 0,
|
|
39
|
+
normalizedArgs
|
|
40
|
+
);
|
|
41
|
+
const [dir, ...packages] = positionals;
|
|
42
|
+
if (!await fs__default.default.pathExists(dir)) {
|
|
43
|
+
throw new Error(`Target workspace directory doesn't exist, '${dir}'`);
|
|
44
|
+
}
|
|
45
|
+
await createDistWorkspace.createDistWorkspace(packages, {
|
|
46
|
+
targetDir: dir,
|
|
47
|
+
alwaysPack,
|
|
48
|
+
enableFeatureDetection: true
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
exports.default = buildWorkspace;
|
|
53
|
+
//# sourceMappingURL=buildWorkspace.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildWorkspace.cjs.js","sources":["../../src/commands/buildWorkspace.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 fs from 'fs-extra';\nimport { cli } from 'cleye';\nimport { createDistWorkspace } from '../lib/packager';\nimport type { CliCommandContext } from '@backstage/cli-node';\n\nexport default async ({ args, info }: CliCommandContext) => {\n // Normalize legacy --alwaysYarnPack alias (a genuinely different name, not\n // just a casing variant — type-flag handles camelCase/kebab-case natively)\n const normalizedArgs = args.map(a => {\n if (a === '--alwaysYarnPack') {\n return '--always-pack';\n }\n if (a.startsWith('--alwaysYarnPack=')) {\n return `--always-pack${a.substring('--alwaysYarnPack'.length)}`;\n }\n return a;\n });\n\n const {\n flags: { alwaysPack },\n _: positionals,\n } = cli(\n {\n help: { ...info, usage: `${info.usage} <workspace-dir> [packages...]` },\n booleanFlagNegation: true,\n parameters: ['<workspace-dir>', '[packages...]'],\n flags: {\n alwaysPack: {\n type: Boolean,\n description:\n 'Force workspace output to be a result of running `yarn pack` on each package (warning: very slow)',\n },\n },\n },\n undefined,\n normalizedArgs,\n );\n\n const [dir, ...packages] = positionals;\n\n if (!(await fs.pathExists(dir))) {\n throw new Error(`Target workspace directory doesn't exist, '${dir}'`);\n }\n\n await createDistWorkspace(packages, {\n targetDir: dir,\n alwaysPack,\n enableFeatureDetection: true,\n });\n};\n"],"names":["cli","fs","createDistWorkspace"],"mappings":";;;;;;;;;;;;AAqBA,qBAAe,OAAO,EAAE,IAAA,EAAM,IAAA,EAAK,KAAyB;AAG1D,EAAA,MAAM,cAAA,GAAiB,IAAA,CAAK,GAAA,CAAI,CAAA,CAAA,KAAK;AACnC,IAAA,IAAI,MAAM,kBAAA,EAAoB;AAC5B,MAAA,OAAO,eAAA;AAAA,IACT;AACA,IAAA,IAAI,CAAA,CAAE,UAAA,CAAW,mBAAmB,CAAA,EAAG;AACrC,MAAA,OAAO,CAAA,aAAA,EAAgB,CAAA,CAAE,SAAA,CAAU,kBAAA,CAAmB,MAAM,CAAC,CAAA,CAAA;AAAA,IAC/D;AACA,IAAA,OAAO,CAAA;AAAA,EACT,CAAC,CAAA;AAED,EAAA,MAAM;AAAA,IACJ,KAAA,EAAO,EAAE,UAAA,EAAW;AAAA,IACpB,CAAA,EAAG;AAAA,GACL,GAAIA,SAAA;AAAA,IACF;AAAA,MACE,IAAA,EAAM,EAAE,GAAG,IAAA,EAAM,OAAO,CAAA,EAAG,IAAA,CAAK,KAAK,CAAA,8BAAA,CAAA,EAAiC;AAAA,MACtE,mBAAA,EAAqB,IAAA;AAAA,MACrB,UAAA,EAAY,CAAC,iBAAA,EAAmB,eAAe,CAAA;AAAA,MAC/C,KAAA,EAAO;AAAA,QACL,UAAA,EAAY;AAAA,UACV,IAAA,EAAM,OAAA;AAAA,UACN,WAAA,EACE;AAAA;AACJ;AACF,KACF;AAAA,IACA,MAAA;AAAA,IACA;AAAA,GACF;AAEA,EAAA,MAAM,CAAC,GAAA,EAAK,GAAG,QAAQ,CAAA,GAAI,WAAA;AAE3B,EAAA,IAAI,CAAE,MAAMC,mBAAA,CAAG,UAAA,CAAW,GAAG,CAAA,EAAI;AAC/B,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,2CAAA,EAA8C,GAAG,CAAA,CAAA,CAAG,CAAA;AAAA,EACtE;AAEA,EAAA,MAAMC,wCAAoB,QAAA,EAAU;AAAA,IAClC,SAAA,EAAW,GAAA;AAAA,IACX,UAAA;AAAA,IACA,sBAAA,EAAwB;AAAA,GACzB,CAAA;AACH,CAAA;;;;"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var cleye = require('cleye');
|
|
6
|
+
var fs = require('fs-extra');
|
|
7
|
+
var packager = require('../../../lib/builder/packager.cjs.js');
|
|
8
|
+
var types = require('../../../lib/builder/types.cjs.js');
|
|
9
|
+
var role = require('../../../lib/role.cjs.js');
|
|
10
|
+
var cliNode = require('@backstage/cli-node');
|
|
11
|
+
var cliCommon = require('@backstage/cli-common');
|
|
12
|
+
var buildFrontend = require('../../../lib/buildFrontend.cjs.js');
|
|
13
|
+
var buildBackend = require('../../../lib/buildBackend.cjs.js');
|
|
14
|
+
var urls = require('../../../lib/urls.cjs.js');
|
|
15
|
+
var chalk = require('chalk');
|
|
16
|
+
|
|
17
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
18
|
+
|
|
19
|
+
var fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
|
|
20
|
+
var chalk__default = /*#__PURE__*/_interopDefaultCompat(chalk);
|
|
21
|
+
|
|
22
|
+
var command = async ({ args, info }) => {
|
|
23
|
+
const {
|
|
24
|
+
flags: {
|
|
25
|
+
role: role$1,
|
|
26
|
+
minify,
|
|
27
|
+
skipBuildDependencies,
|
|
28
|
+
stats,
|
|
29
|
+
config,
|
|
30
|
+
moduleFederation
|
|
31
|
+
}
|
|
32
|
+
} = cleye.cli(
|
|
33
|
+
{
|
|
34
|
+
help: info,
|
|
35
|
+
booleanFlagNegation: true,
|
|
36
|
+
flags: {
|
|
37
|
+
role: {
|
|
38
|
+
type: String,
|
|
39
|
+
description: "Run the command with an explicit package role"
|
|
40
|
+
},
|
|
41
|
+
minify: {
|
|
42
|
+
type: Boolean,
|
|
43
|
+
description: "Minify the generated code. Does not apply to app package (app is minified by default)."
|
|
44
|
+
},
|
|
45
|
+
skipBuildDependencies: {
|
|
46
|
+
type: Boolean,
|
|
47
|
+
description: "Skip the automatic building of local dependencies. Applies to backend packages only."
|
|
48
|
+
},
|
|
49
|
+
stats: {
|
|
50
|
+
type: Boolean,
|
|
51
|
+
description: "If bundle stats are available, write them to the output directory. Applies to app packages only."
|
|
52
|
+
},
|
|
53
|
+
config: {
|
|
54
|
+
type: [String],
|
|
55
|
+
description: "Config files to load instead of app-config.yaml. Applies to app packages only.",
|
|
56
|
+
default: []
|
|
57
|
+
},
|
|
58
|
+
moduleFederation: {
|
|
59
|
+
type: Boolean,
|
|
60
|
+
description: "Build a package as a module federation remote. Applies to frontend plugin packages only."
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
void 0,
|
|
65
|
+
args
|
|
66
|
+
);
|
|
67
|
+
const webpack = process.env.LEGACY_WEBPACK_BUILD ? require("webpack") : void 0;
|
|
68
|
+
const resolvedRole = await role.findRoleFromCommand({ role: role$1 });
|
|
69
|
+
if (resolvedRole === "frontend" || resolvedRole === "backend") {
|
|
70
|
+
const configPaths = config.map((arg) => {
|
|
71
|
+
if (urls.isValidUrl(arg)) {
|
|
72
|
+
return arg;
|
|
73
|
+
}
|
|
74
|
+
return cliCommon.targetPaths.resolve(arg);
|
|
75
|
+
});
|
|
76
|
+
if (resolvedRole === "frontend") {
|
|
77
|
+
return buildFrontend.buildFrontend({
|
|
78
|
+
targetDir: cliCommon.targetPaths.dir,
|
|
79
|
+
configPaths,
|
|
80
|
+
writeStats: Boolean(stats),
|
|
81
|
+
webpack
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
return buildBackend.buildBackend({
|
|
85
|
+
targetDir: cliCommon.targetPaths.dir,
|
|
86
|
+
configPaths,
|
|
87
|
+
skipBuildDependencies: Boolean(skipBuildDependencies),
|
|
88
|
+
minify: Boolean(minify)
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
let isModuleFederationRemote = void 0;
|
|
92
|
+
if (resolvedRole === "frontend-dynamic-container") {
|
|
93
|
+
console.log(
|
|
94
|
+
chalk__default.default.yellow(
|
|
95
|
+
`\u26A0\uFE0F WARNING: The 'frontend-dynamic-container' package role is experimental and will receive immediate breaking changes in the future.`
|
|
96
|
+
)
|
|
97
|
+
);
|
|
98
|
+
isModuleFederationRemote = true;
|
|
99
|
+
}
|
|
100
|
+
if (moduleFederation) {
|
|
101
|
+
isModuleFederationRemote = true;
|
|
102
|
+
}
|
|
103
|
+
if (isModuleFederationRemote) {
|
|
104
|
+
console.log("Building package as a module federation remote");
|
|
105
|
+
return buildFrontend.buildFrontend({
|
|
106
|
+
targetDir: cliCommon.targetPaths.dir,
|
|
107
|
+
configPaths: [],
|
|
108
|
+
writeStats: Boolean(stats),
|
|
109
|
+
isModuleFederationRemote,
|
|
110
|
+
webpack
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
const roleInfo = cliNode.PackageRoles.getRoleInfo(resolvedRole);
|
|
114
|
+
const outputs = /* @__PURE__ */ new Set();
|
|
115
|
+
if (roleInfo.output.includes("cjs")) {
|
|
116
|
+
outputs.add(types.Output.cjs);
|
|
117
|
+
}
|
|
118
|
+
if (roleInfo.output.includes("esm")) {
|
|
119
|
+
outputs.add(types.Output.esm);
|
|
120
|
+
}
|
|
121
|
+
if (roleInfo.output.includes("types")) {
|
|
122
|
+
outputs.add(types.Output.types);
|
|
123
|
+
}
|
|
124
|
+
const packageJson = await fs__default.default.readJson(
|
|
125
|
+
cliCommon.targetPaths.resolve("package.json")
|
|
126
|
+
);
|
|
127
|
+
return packager.buildPackage({
|
|
128
|
+
outputs,
|
|
129
|
+
packageJson,
|
|
130
|
+
minify: Boolean(minify),
|
|
131
|
+
workspacePackages: await cliNode.PackageGraph.listTargetPackages()
|
|
132
|
+
});
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
exports.default = command;
|
|
136
|
+
//# sourceMappingURL=command.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.cjs.js","sources":["../../../../src/commands/package/build/command.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 fs from 'fs-extra';\nimport { buildPackage, Output } from '../../../lib/builder';\nimport { findRoleFromCommand } from '../../../lib/role';\nimport {\n BackstagePackageJson,\n PackageGraph,\n PackageRoles,\n} from '@backstage/cli-node';\nimport { targetPaths } from '@backstage/cli-common';\n\nimport { buildFrontend } from '../../../lib/buildFrontend';\nimport { buildBackend } from '../../../lib/buildBackend';\nimport { isValidUrl } from '../../../lib/urls';\nimport chalk from 'chalk';\nimport type { CliCommandContext } from '@backstage/cli-node';\n\nexport default async ({ args, info }: CliCommandContext) => {\n const {\n flags: {\n role,\n minify,\n skipBuildDependencies,\n stats,\n config,\n moduleFederation,\n },\n } = cli(\n {\n help: info,\n booleanFlagNegation: true,\n flags: {\n role: {\n type: String,\n description: 'Run the command with an explicit package role',\n },\n minify: {\n type: Boolean,\n description:\n 'Minify the generated code. Does not apply to app package (app is minified by default).',\n },\n skipBuildDependencies: {\n type: Boolean,\n description:\n 'Skip the automatic building of local dependencies. Applies to backend packages only.',\n },\n stats: {\n type: Boolean,\n description:\n 'If bundle stats are available, write them to the output directory. Applies to app packages only.',\n },\n config: {\n type: [String],\n description:\n 'Config files to load instead of app-config.yaml. Applies to app packages only.',\n default: [],\n },\n moduleFederation: {\n type: Boolean,\n description:\n 'Build a package as a module federation remote. Applies to frontend plugin packages only.',\n },\n },\n },\n undefined,\n args,\n );\n\n const webpack = process.env.LEGACY_WEBPACK_BUILD\n ? (require('webpack') as typeof import('webpack'))\n : undefined;\n\n const resolvedRole = await findRoleFromCommand({ role });\n\n if (resolvedRole === 'frontend' || resolvedRole === 'backend') {\n const configPaths = config.map(arg => {\n if (isValidUrl(arg)) {\n return arg;\n }\n return targetPaths.resolve(arg);\n });\n\n if (resolvedRole === 'frontend') {\n return buildFrontend({\n targetDir: targetPaths.dir,\n configPaths,\n writeStats: Boolean(stats),\n webpack,\n });\n }\n return buildBackend({\n targetDir: targetPaths.dir,\n configPaths,\n skipBuildDependencies: Boolean(skipBuildDependencies),\n minify: Boolean(minify),\n });\n }\n\n let isModuleFederationRemote: boolean | undefined = undefined;\n if ((resolvedRole as string) === 'frontend-dynamic-container') {\n console.log(\n chalk.yellow(\n `⚠️ WARNING: The 'frontend-dynamic-container' package role is experimental and will receive immediate breaking changes in the future.`,\n ),\n );\n isModuleFederationRemote = true;\n }\n if (moduleFederation) {\n isModuleFederationRemote = true;\n }\n\n if (isModuleFederationRemote) {\n console.log('Building package as a module federation remote');\n return buildFrontend({\n targetDir: targetPaths.dir,\n configPaths: [],\n writeStats: Boolean(stats),\n isModuleFederationRemote,\n webpack,\n });\n }\n\n const roleInfo = PackageRoles.getRoleInfo(resolvedRole);\n\n const outputs = new Set<Output>();\n\n if (roleInfo.output.includes('cjs')) {\n outputs.add(Output.cjs);\n }\n if (roleInfo.output.includes('esm')) {\n outputs.add(Output.esm);\n }\n if (roleInfo.output.includes('types')) {\n outputs.add(Output.types);\n }\n\n const packageJson = (await fs.readJson(\n targetPaths.resolve('package.json'),\n )) as BackstagePackageJson;\n\n return buildPackage({\n outputs,\n packageJson,\n minify: Boolean(minify),\n workspacePackages: await PackageGraph.listTargetPackages(),\n });\n};\n"],"names":["role","cli","findRoleFromCommand","isValidUrl","targetPaths","buildFrontend","buildBackend","chalk","PackageRoles","Output","fs","buildPackage","PackageGraph"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAiCA,cAAe,OAAO,EAAE,IAAA,EAAM,IAAA,EAAK,KAAyB;AAC1D,EAAA,MAAM;AAAA,IACJ,KAAA,EAAO;AAAA,YACLA,MAAA;AAAA,MACA,MAAA;AAAA,MACA,qBAAA;AAAA,MACA,KAAA;AAAA,MACA,MAAA;AAAA,MACA;AAAA;AACF,GACF,GAAIC,SAAA;AAAA,IACF;AAAA,MACE,IAAA,EAAM,IAAA;AAAA,MACN,mBAAA,EAAqB,IAAA;AAAA,MACrB,KAAA,EAAO;AAAA,QACL,IAAA,EAAM;AA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