@backstage/cli 0.36.0-next.2 → 0.36.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.
- package/CHANGELOG.md +95 -0
- package/config/eslint-factory.js +1 -0
- package/config/getJestEnvironment.js +7 -29
- package/config/jest-environment-jsdom/index.js +9 -43
- package/config/jest.js +7 -401
- package/config/jestCacheResultProcessor.cjs +10 -6
- package/config/jestCachingModuleLoader.js +11 -19
- package/config/jestFileTransform.js +11 -28
- package/config/jestRejectNetworkRequests.js +10 -53
- package/config/jestSucraseTransform.js +10 -70
- package/config/jestSwcTransform.js +10 -27
- package/config/jestYamlTransform.js +11 -24
- package/config/nodeTransform.cjs +10 -70
- package/config/nodeTransformHooks.mjs +4 -278
- package/config/webpack-public-path.js +10 -14
- package/dist/cli-internal/src/InternalCliModule.cjs.js +11 -0
- package/dist/cli-internal/src/InternalCommandNode.cjs.js +25 -0
- package/dist/cli-internal/src/knownPluginPackages.cjs.js +40 -0
- package/dist/index.cjs.js +21 -11
- package/dist/wiring/CliInitializer.cjs.js +61 -30
- package/dist/wiring/CommandGraph.cjs.js +81 -23
- package/dist/wiring/discoverCliModules.cjs.js +44 -0
- package/package.json +27 -160
- package/dist/modules/auth/commands/list.cjs.js +0 -23
- package/dist/modules/auth/commands/login.cjs.js +0 -316
- package/dist/modules/auth/commands/logout.cjs.js +0 -55
- package/dist/modules/auth/commands/printToken.cjs.js +0 -41
- package/dist/modules/auth/commands/select.cjs.js +0 -32
- package/dist/modules/auth/commands/show.cjs.js +0 -59
- package/dist/modules/auth/index.cjs.js +0 -44
- package/dist/modules/auth/lib/auth.cjs.js +0 -60
- package/dist/modules/auth/lib/http.cjs.js +0 -26
- package/dist/modules/auth/lib/localServer.cjs.js +0 -80
- package/dist/modules/auth/lib/pkce.cjs.js +0 -23
- package/dist/modules/auth/lib/prompt.cjs.js +0 -44
- package/dist/modules/auth/lib/secretStore.cjs.js +0 -81
- package/dist/modules/auth/lib/storage.cjs.js +0 -152
- package/dist/modules/build/commands/buildWorkspace.cjs.js +0 -53
- package/dist/modules/build/commands/package/build/command.cjs.js +0 -136
- package/dist/modules/build/commands/package/build/index.cjs.js +0 -10
- package/dist/modules/build/commands/package/clean.cjs.js +0 -21
- package/dist/modules/build/commands/package/postpack.cjs.js +0 -15
- package/dist/modules/build/commands/package/prepack.cjs.js +0 -29
- package/dist/modules/build/commands/package/start/command.cjs.js +0 -80
- package/dist/modules/build/commands/package/start/index.cjs.js +0 -10
- package/dist/modules/build/commands/package/start/resolveLinkedWorkspace.cjs.js +0 -34
- package/dist/modules/build/commands/package/start/startBackend.cjs.js +0 -46
- package/dist/modules/build/commands/package/start/startFrontend.cjs.js +0 -50
- package/dist/modules/build/commands/package/start/startPackage.cjs.js +0 -53
- package/dist/modules/build/commands/repo/build.cjs.js +0 -149
- package/dist/modules/build/commands/repo/clean.cjs.js +0 -41
- package/dist/modules/build/commands/repo/start.cjs.js +0 -199
- package/dist/modules/build/index.cjs.js +0 -68
- package/dist/modules/build/lib/buildBackend.cjs.js +0 -81
- package/dist/modules/build/lib/buildFrontend.cjs.js +0 -50
- package/dist/modules/build/lib/builder/config.cjs.js +0 -257
- package/dist/modules/build/lib/builder/packager.cjs.js +0 -131
- package/dist/modules/build/lib/builder/plugins.cjs.js +0 -125
- package/dist/modules/build/lib/builder/types.cjs.js +0 -10
- package/dist/modules/build/lib/bundler/ConfigInjectingHtmlWebpackPlugin.cjs.js +0 -43
- package/dist/modules/build/lib/bundler/bundle.cjs.js +0 -189
- package/dist/modules/build/lib/bundler/config.cjs.js +0 -308
- package/dist/modules/build/lib/bundler/hasReactDomClient.cjs.js +0 -17
- package/dist/modules/build/lib/bundler/linkWorkspaces.cjs.js +0 -34
- package/dist/modules/build/lib/bundler/moduleFederation.cjs.js +0 -135
- package/dist/modules/build/lib/bundler/optimization.cjs.js +0 -68
- package/dist/modules/build/lib/bundler/packageDetection.cjs.js +0 -124
- package/dist/modules/build/lib/bundler/paths.cjs.js +0 -62
- package/dist/modules/build/lib/bundler/server.cjs.js +0 -231
- package/dist/modules/build/lib/bundler/transforms.cjs.js +0 -145
- package/dist/modules/build/lib/config.cjs.js +0 -94
- package/dist/modules/build/lib/entryPoints.cjs.js +0 -49
- package/dist/modules/build/lib/ipc/IpcServer.cjs.js +0 -60
- package/dist/modules/build/lib/ipc/ServerDataStore.cjs.js +0 -36
- package/dist/modules/build/lib/optionsParser.cjs.js +0 -22
- package/dist/modules/build/lib/packager/createDistWorkspace.cjs.js +0 -235
- package/dist/modules/build/lib/packager/productionPack.cjs.js +0 -160
- package/dist/modules/build/lib/publishing.cjs.js +0 -40
- package/dist/modules/build/lib/role.cjs.js +0 -24
- package/dist/modules/build/lib/runner/runBackend.cjs.js +0 -136
- package/dist/modules/build/lib/typeDistProject.cjs.js +0 -89
- package/dist/modules/build/lib/urls.cjs.js +0 -13
- package/dist/modules/config/commands/docs.cjs.js +0 -63
- package/dist/modules/config/commands/print.cjs.js +0 -81
- package/dist/modules/config/commands/schema.cjs.js +0 -56
- package/dist/modules/config/commands/validate.cjs.js +0 -50
- package/dist/modules/config/index.cjs.js +0 -51
- package/dist/modules/config/lib/config.cjs.js +0 -94
- package/dist/modules/create-github-app/commands/create-github-app/GithubCreateAppServer.cjs.js +0 -127
- package/dist/modules/create-github-app/commands/create-github-app/index.cjs.js +0 -126
- package/dist/modules/create-github-app/index.cjs.js +0 -19
- package/dist/modules/info/commands/info.cjs.js +0 -182
- package/dist/modules/info/index.cjs.js +0 -19
- package/dist/modules/lint/commands/package/lint.cjs.js +0 -78
- package/dist/modules/lint/commands/repo/lint.cjs.js +0 -282
- package/dist/modules/lint/index.cjs.js +0 -24
- package/dist/modules/lint/lib/optionsParser.cjs.js +0 -22
- package/dist/modules/maintenance/commands/repo/fix.cjs.js +0 -426
- package/dist/modules/maintenance/commands/repo/list-deprecations.cjs.js +0 -90
- package/dist/modules/maintenance/index.cjs.js +0 -24
- package/dist/modules/migrate/commands/packageExports.cjs.js +0 -15
- package/dist/modules/migrate/commands/packageLintConfigs.cjs.js +0 -77
- package/dist/modules/migrate/commands/packageRole.cjs.js +0 -57
- package/dist/modules/migrate/commands/packageScripts.cjs.js +0 -87
- package/dist/modules/migrate/commands/reactRouterDeps.cjs.js +0 -51
- package/dist/modules/migrate/commands/versions/bump.cjs.js +0 -403
- package/dist/modules/migrate/commands/versions/migrate.cjs.js +0 -133
- package/dist/modules/migrate/index.cjs.js +0 -59
- package/dist/modules/migrate/lib/utils.cjs.js +0 -44
- package/dist/modules/migrate/lib/versioning/packages.cjs.js +0 -71
- package/dist/modules/migrate/lib/versioning/yarn.cjs.js +0 -28
- package/dist/modules/new/commands/new.cjs.js +0 -115
- package/dist/modules/new/index.cjs.js +0 -40
- package/dist/modules/new/lib/codeowners/codeowners.cjs.js +0 -92
- package/dist/modules/new/lib/createNewPackage.cjs.js +0 -32
- package/dist/modules/new/lib/defaultTemplates.cjs.js +0 -17
- package/dist/modules/new/lib/execution/PortableTemplater.cjs.js +0 -89
- package/dist/modules/new/lib/execution/executePortableTemplate.cjs.js +0 -66
- package/dist/modules/new/lib/execution/installNewPackage.cjs.js +0 -127
- package/dist/modules/new/lib/execution/writeTemplateContents.cjs.js +0 -116
- package/dist/modules/new/lib/preparation/collectPortableTemplateInput.cjs.js +0 -157
- package/dist/modules/new/lib/preparation/loadPortableTemplate.cjs.js +0 -81
- package/dist/modules/new/lib/preparation/loadPortableTemplateConfig.cjs.js +0 -132
- package/dist/modules/new/lib/preparation/resolvePackageParams.cjs.js +0 -40
- package/dist/modules/new/lib/preparation/selectTemplateInteractively.cjs.js +0 -38
- package/dist/modules/new/lib/tasks.cjs.js +0 -51
- package/dist/modules/new/lib/types.cjs.js +0 -19
- package/dist/modules/new/lib/version.cjs.js +0 -91
- package/dist/modules/test/commands/package/test.cjs.js +0 -59
- package/dist/modules/test/commands/repo/test.cjs.js +0 -299
- package/dist/modules/test/index.cjs.js +0 -24
- package/dist/modules/translations/commands/export.cjs.js +0 -128
- package/dist/modules/translations/commands/import.cjs.js +0 -165
- package/dist/modules/translations/index.cjs.js +0 -24
- package/dist/modules/translations/lib/discoverPackages.cjs.js +0 -121
- package/dist/modules/translations/lib/extractTranslations.cjs.js +0 -71
- package/dist/modules/translations/lib/messageFilePath.cjs.js +0 -43
- package/dist/packages/backend-defaults/package.json.cjs.js +0 -6
- package/dist/packages/backend-plugin-api/package.json.cjs.js +0 -6
- package/dist/packages/backend-test-utils/package.json.cjs.js +0 -6
- package/dist/packages/catalog-client/package.json.cjs.js +0 -6
- package/dist/packages/cli/package.json.cjs.js +0 -159
- package/dist/packages/config/package.json.cjs.js +0 -6
- package/dist/packages/core-app-api/package.json.cjs.js +0 -6
- package/dist/packages/core-components/package.json.cjs.js +0 -6
- package/dist/packages/core-plugin-api/package.json.cjs.js +0 -6
- package/dist/packages/dev-utils/package.json.cjs.js +0 -6
- package/dist/packages/errors/package.json.cjs.js +0 -6
- package/dist/packages/frontend-defaults/package.json.cjs.js +0 -6
- package/dist/packages/frontend-plugin-api/package.json.cjs.js +0 -6
- package/dist/packages/frontend-plugin-api/src/routing/describeParentCallSite.cjs.js +0 -26
- package/dist/packages/frontend-test-utils/package.json.cjs.js +0 -6
- package/dist/packages/test-utils/package.json.cjs.js +0 -6
- package/dist/packages/theme/package.json.cjs.js +0 -6
- package/dist/packages/types/package.json.cjs.js +0 -6
- package/dist/plugins/auth-backend/package.json.cjs.js +0 -6
- package/dist/plugins/auth-backend-module-guest-provider/package.json.cjs.js +0 -6
- package/dist/plugins/catalog-node/package.json.cjs.js +0 -6
- package/dist/plugins/scaffolder-node/package.json.cjs.js +0 -6
- package/dist/plugins/scaffolder-node-test-utils/package.json.cjs.js +0 -6
- package/dist/wiring/CommandRegistry.cjs.js +0 -14
- package/dist/wiring/factory.cjs.js +0 -15
- package/dist/wiring/types.cjs.js +0 -11
- package/templates/backend-plugin/.eslintrc.js.hbs +0 -1
- package/templates/backend-plugin/README.md.hbs +0 -28
- package/templates/backend-plugin/dev/index.ts.hbs +0 -60
- package/templates/backend-plugin/package.json.hbs +0 -44
- package/templates/backend-plugin/portable-template.yaml +0 -5
- package/templates/backend-plugin/src/index.ts.hbs +0 -1
- package/templates/backend-plugin/src/plugin.test.ts.hbs +0 -129
- package/templates/backend-plugin/src/plugin.ts.hbs +0 -32
- package/templates/backend-plugin/src/router.test.ts +0 -67
- package/templates/backend-plugin/src/router.ts +0 -51
- package/templates/backend-plugin/src/services/TodoListService.ts +0 -155
- package/templates/backend-plugin/src/setupTests.ts +0 -1
- package/templates/backend-plugin-module/.eslintrc.js.hbs +0 -1
- package/templates/backend-plugin-module/README.md.hbs +0 -5
- package/templates/backend-plugin-module/package.json.hbs +0 -34
- package/templates/backend-plugin-module/portable-template.yaml +0 -5
- package/templates/backend-plugin-module/src/index.ts.hbs +0 -8
- package/templates/backend-plugin-module/src/module.ts.hbs +0 -17
- package/templates/catalog-provider-module/.eslintrc.js.hbs +0 -1
- package/templates/catalog-provider-module/README.md.hbs +0 -5
- package/templates/catalog-provider-module/config.d.ts.hbs +0 -34
- package/templates/catalog-provider-module/package.json.hbs +0 -36
- package/templates/catalog-provider-module/portable-template.yaml +0 -9
- package/templates/catalog-provider-module/src/index.ts.hbs +0 -8
- package/templates/catalog-provider-module/src/module.ts.hbs +0 -29
- package/templates/catalog-provider-module/src/provider/readProviderConfigs.ts.hbs +0 -78
- package/templates/catalog-provider-module/src/provider/{{providerClass}}.test.ts.hbs +0 -18
- package/templates/catalog-provider-module/src/provider/{{providerClass}}.ts.hbs +0 -109
- package/templates/frontend-plugin/.eslintrc.js.hbs +0 -1
- package/templates/frontend-plugin/README.md.hbs +0 -13
- package/templates/frontend-plugin/dev/index.tsx.hbs +0 -11
- package/templates/frontend-plugin/package.json.hbs +0 -54
- package/templates/frontend-plugin/portable-template.yaml +0 -6
- package/templates/frontend-plugin/src/components/ExampleComponent/ExampleComponent.test.tsx.hbs +0 -28
- package/templates/frontend-plugin/src/components/ExampleComponent/ExampleComponent.tsx.hbs +0 -37
- package/templates/frontend-plugin/src/components/ExampleComponent/index.ts +0 -1
- package/templates/frontend-plugin/src/components/ExampleFetchComponent/ExampleFetchComponent.test.tsx.hbs +0 -19
- package/templates/frontend-plugin/src/components/ExampleFetchComponent/ExampleFetchComponent.tsx.hbs +0 -308
- package/templates/frontend-plugin/src/components/ExampleFetchComponent/index.ts +0 -1
- package/templates/frontend-plugin/src/index.ts.hbs +0 -1
- package/templates/frontend-plugin/src/plugin.test.ts.hbs +0 -7
- package/templates/frontend-plugin/src/plugin.ts.hbs +0 -22
- package/templates/frontend-plugin/src/routes.ts.hbs +0 -5
- package/templates/frontend-plugin/src/setupTests.ts +0 -1
- package/templates/new-frontend-plugin/.eslintrc.js.hbs +0 -1
- package/templates/new-frontend-plugin/README.md.hbs +0 -20
- package/templates/new-frontend-plugin/dev/index.tsx +0 -10
- package/templates/new-frontend-plugin/package.json.hbs +0 -49
- package/templates/new-frontend-plugin/portable-template.yaml +0 -5
- package/templates/new-frontend-plugin/src/components/ExampleComponent/ExampleComponent.test.tsx.hbs +0 -28
- package/templates/new-frontend-plugin/src/components/ExampleComponent/ExampleComponent.tsx.hbs +0 -37
- package/templates/new-frontend-plugin/src/components/ExampleComponent/index.ts +0 -1
- package/templates/new-frontend-plugin/src/components/ExampleFetchComponent/ExampleFetchComponent.test.tsx.hbs +0 -19
- package/templates/new-frontend-plugin/src/components/ExampleFetchComponent/ExampleFetchComponent.tsx.hbs +0 -308
- package/templates/new-frontend-plugin/src/components/ExampleFetchComponent/index.ts +0 -1
- package/templates/new-frontend-plugin/src/index.ts.hbs +0 -1
- package/templates/new-frontend-plugin/src/plugin.test.ts.hbs +0 -7
- package/templates/new-frontend-plugin/src/plugin.tsx.hbs +0 -25
- package/templates/new-frontend-plugin/src/routes.ts +0 -3
- package/templates/new-frontend-plugin/src/setupTests.ts +0 -1
- package/templates/new-frontend-plugin-module/.eslintrc.js.hbs +0 -1
- package/templates/new-frontend-plugin-module/README.md.hbs +0 -5
- package/templates/new-frontend-plugin-module/package.json.hbs +0 -35
- package/templates/new-frontend-plugin-module/portable-template.yaml +0 -5
- package/templates/new-frontend-plugin-module/src/index.ts.hbs +0 -1
- package/templates/new-frontend-plugin-module/src/module.tsx.hbs +0 -8
- package/templates/new-frontend-plugin-module/src/setupTests.ts +0 -1
- package/templates/node-library/.eslintrc.js.hbs +0 -1
- package/templates/node-library/README.md.hbs +0 -12
- package/templates/node-library/package.json.hbs +0 -29
- package/templates/node-library/portable-template.yaml +0 -3
- package/templates/node-library/src/index.ts.hbs +0 -1
- package/templates/node-library/src/setupTests.ts +0 -1
- package/templates/plugin-common-library/.eslintrc.js.hbs +0 -1
- package/templates/plugin-common-library/README.md.hbs +0 -5
- package/templates/plugin-common-library/package.json.hbs +0 -31
- package/templates/plugin-common-library/portable-template.yaml +0 -3
- package/templates/plugin-common-library/src/index.ts.hbs +0 -19
- package/templates/plugin-common-library/src/setupTests.ts +0 -1
- package/templates/plugin-node-library/.eslintrc.js.hbs +0 -1
- package/templates/plugin-node-library/README.md.hbs +0 -5
- package/templates/plugin-node-library/package.json.hbs +0 -30
- package/templates/plugin-node-library/portable-template.yaml +0 -3
- package/templates/plugin-node-library/src/index.ts.hbs +0 -18
- package/templates/plugin-node-library/src/setupTests.ts +0 -1
- package/templates/plugin-web-library/.eslintrc.js.hbs +0 -1
- package/templates/plugin-web-library/README.md.hbs +0 -5
- package/templates/plugin-web-library/package.json.hbs +0 -42
- package/templates/plugin-web-library/portable-template.yaml +0 -3
- package/templates/plugin-web-library/src/components/ExampleComponent/ExampleComponent.test.tsx +0 -17
- package/templates/plugin-web-library/src/components/ExampleComponent/ExampleComponent.tsx +0 -28
- package/templates/plugin-web-library/src/components/ExampleComponent/index.ts +0 -2
- package/templates/plugin-web-library/src/components/index.ts +0 -5
- package/templates/plugin-web-library/src/hooks/index.ts +0 -5
- package/templates/plugin-web-library/src/hooks/useExample/index.ts +0 -1
- package/templates/plugin-web-library/src/hooks/useExample/useExample.ts +0 -15
- package/templates/plugin-web-library/src/index.ts.hbs +0 -12
- package/templates/plugin-web-library/src/setupTests.ts +0 -1
- package/templates/scaffolder-backend-module/.eslintrc.js.hbs +0 -1
- package/templates/scaffolder-backend-module/README.md.hbs +0 -5
- package/templates/scaffolder-backend-module/package.json.hbs +0 -36
- package/templates/scaffolder-backend-module/portable-template.yaml +0 -6
- package/templates/scaffolder-backend-module/src/actions/example.test.ts +0 -24
- package/templates/scaffolder-backend-module/src/actions/example.ts +0 -39
- package/templates/scaffolder-backend-module/src/index.ts.hbs +0 -8
- package/templates/scaffolder-backend-module/src/module.ts +0 -21
- package/templates/web-library/.eslintrc.js.hbs +0 -1
- package/templates/web-library/README.md.hbs +0 -12
- package/templates/web-library/package.json.hbs +0 -30
- package/templates/web-library/portable-template.yaml +0 -3
- package/templates/web-library/src/index.ts.hbs +0 -1
- package/templates/web-library/src/setupTests.ts +0 -1
- /package/dist/{packages/opaque-internal → opaque-internal}/src/OpaqueType.cjs.js +0 -0
|
@@ -1,426 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var cliNode = require('@backstage/cli-node');
|
|
6
|
-
var cleye = require('cleye');
|
|
7
|
-
var fs = require('fs-extra');
|
|
8
|
-
var path = require('node:path');
|
|
9
|
-
var cliCommon = require('@backstage/cli-common');
|
|
10
|
-
|
|
11
|
-
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
12
|
-
|
|
13
|
-
var fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
|
|
14
|
-
|
|
15
|
-
const SCRIPT_EXTS = [".js", ".jsx", ".ts", ".tsx", ".json"];
|
|
16
|
-
async function readFixablePackages() {
|
|
17
|
-
const packages = await cliNode.PackageGraph.listTargetPackages();
|
|
18
|
-
return packages.map((pkg) => ({ ...pkg, changed: false }));
|
|
19
|
-
}
|
|
20
|
-
function printPackageFixHint(packages) {
|
|
21
|
-
const changed = packages.filter((pkg) => pkg.changed);
|
|
22
|
-
if (changed.length > 0) {
|
|
23
|
-
const rootPkg = require(cliCommon.targetPaths.resolveRoot("package.json"));
|
|
24
|
-
const fixCmd = rootPkg.scripts?.fix === "backstage-cli repo fix" ? "fix" : "backstage-cli repo fix";
|
|
25
|
-
console.log(
|
|
26
|
-
`The following packages are out of sync, run 'yarn ${fixCmd}' to fix them:`
|
|
27
|
-
);
|
|
28
|
-
for (const pkg of changed) {
|
|
29
|
-
console.log(` ${pkg.packageJson.name}`);
|
|
30
|
-
}
|
|
31
|
-
return true;
|
|
32
|
-
}
|
|
33
|
-
return false;
|
|
34
|
-
}
|
|
35
|
-
async function writeFixedPackages(packages) {
|
|
36
|
-
await Promise.all(
|
|
37
|
-
packages.map(async (pkg) => {
|
|
38
|
-
if (!pkg.changed) {
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
await fs__default.default.writeJson(
|
|
42
|
-
path.resolve(pkg.dir, "package.json"),
|
|
43
|
-
pkg.packageJson,
|
|
44
|
-
{
|
|
45
|
-
spaces: 2
|
|
46
|
-
}
|
|
47
|
-
);
|
|
48
|
-
})
|
|
49
|
-
);
|
|
50
|
-
}
|
|
51
|
-
function trimRelative(path) {
|
|
52
|
-
if (path.startsWith("./")) {
|
|
53
|
-
return path.slice(2);
|
|
54
|
-
}
|
|
55
|
-
return path;
|
|
56
|
-
}
|
|
57
|
-
function fixPackageExports(pkg) {
|
|
58
|
-
let { exports: exp } = pkg.packageJson;
|
|
59
|
-
if (!exp) {
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
if (Array.isArray(exp)) {
|
|
63
|
-
throw new Error("Unexpected array in package.json exports field");
|
|
64
|
-
}
|
|
65
|
-
if (typeof exp === "string") {
|
|
66
|
-
pkg.changed = true;
|
|
67
|
-
exp = { ".": exp };
|
|
68
|
-
pkg.packageJson.exports = exp;
|
|
69
|
-
} else if (typeof exp !== "object") {
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
if (!exp["./package.json"]) {
|
|
73
|
-
pkg.changed = true;
|
|
74
|
-
exp["./package.json"] = "./package.json";
|
|
75
|
-
}
|
|
76
|
-
const existingTypesVersions = JSON.stringify(pkg.packageJson.typesVersions);
|
|
77
|
-
const typeEntries = {};
|
|
78
|
-
for (const [path$1, value] of Object.entries(exp)) {
|
|
79
|
-
if (path$1 === ".") {
|
|
80
|
-
continue;
|
|
81
|
-
}
|
|
82
|
-
const newPath = trimRelative(path$1);
|
|
83
|
-
if (typeof value === "string") {
|
|
84
|
-
if (SCRIPT_EXTS.includes(path.extname(value))) {
|
|
85
|
-
typeEntries[newPath] = [trimRelative(value)];
|
|
86
|
-
}
|
|
87
|
-
} else if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
88
|
-
if (typeof value.types === "string") {
|
|
89
|
-
typeEntries[newPath] = [trimRelative(value.types)];
|
|
90
|
-
} else if (typeof value.default === "string" && SCRIPT_EXTS.includes(path.extname(value.default))) {
|
|
91
|
-
typeEntries[newPath] = [trimRelative(value.default)];
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
const hasTypeEntries = Object.keys(typeEntries).length > 0;
|
|
96
|
-
const typesVersions = hasTypeEntries ? { "*": typeEntries } : void 0;
|
|
97
|
-
if (existingTypesVersions !== JSON.stringify(typesVersions)) {
|
|
98
|
-
if (pkg.packageJson.typesVersions) {
|
|
99
|
-
if (typesVersions) {
|
|
100
|
-
pkg.packageJson.typesVersions = typesVersions;
|
|
101
|
-
} else {
|
|
102
|
-
delete pkg.packageJson.typesVersions;
|
|
103
|
-
}
|
|
104
|
-
} else if (typesVersions) {
|
|
105
|
-
const newPkgEntries = Object.entries(pkg.packageJson);
|
|
106
|
-
newPkgEntries.splice(
|
|
107
|
-
newPkgEntries.findIndex(([name]) => name === "exports") + 1,
|
|
108
|
-
0,
|
|
109
|
-
["typesVersions", typesVersions]
|
|
110
|
-
);
|
|
111
|
-
pkg.packageJson = Object.fromEntries(
|
|
112
|
-
newPkgEntries
|
|
113
|
-
);
|
|
114
|
-
}
|
|
115
|
-
pkg.changed = true;
|
|
116
|
-
}
|
|
117
|
-
const publishConfig = pkg.packageJson.publishConfig;
|
|
118
|
-
if (publishConfig) {
|
|
119
|
-
for (const field of ["main", "module", "browser", "types"]) {
|
|
120
|
-
if (publishConfig[field]) {
|
|
121
|
-
delete publishConfig[field];
|
|
122
|
-
pkg.changed = true;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
function fixSideEffects(pkg) {
|
|
128
|
-
const role = cliNode.PackageRoles.getRoleFromPackage(pkg.packageJson);
|
|
129
|
-
if (!role) {
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
const roleInfo = cliNode.PackageRoles.getRoleInfo(role);
|
|
133
|
-
if (roleInfo.platform === "node") {
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
if (roleInfo.output.length === 1 && roleInfo.output[0] === "bundle") {
|
|
137
|
-
return;
|
|
138
|
-
}
|
|
139
|
-
if ("sideEffects" in pkg.packageJson) {
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
142
|
-
const pkgEntries = Object.entries(pkg.packageJson);
|
|
143
|
-
pkgEntries.splice(
|
|
144
|
-
// Place it just above the scripts field
|
|
145
|
-
pkgEntries.findIndex(([name]) => name === "scripts"),
|
|
146
|
-
0,
|
|
147
|
-
["sideEffects", false]
|
|
148
|
-
);
|
|
149
|
-
pkg.packageJson = Object.fromEntries(pkgEntries);
|
|
150
|
-
pkg.changed = true;
|
|
151
|
-
}
|
|
152
|
-
function createRepositoryFieldFixer() {
|
|
153
|
-
const rootPkg = require(cliCommon.targetPaths.resolveRoot("package.json"));
|
|
154
|
-
const rootRepoField = rootPkg.repository;
|
|
155
|
-
if (!rootRepoField) {
|
|
156
|
-
return () => {
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
const rootType = rootRepoField.type || "git";
|
|
160
|
-
const rootUrl = rootRepoField.url;
|
|
161
|
-
const rootDir = rootRepoField.directory || "";
|
|
162
|
-
return (pkg) => {
|
|
163
|
-
const expectedPath = path.posix.join(
|
|
164
|
-
rootDir,
|
|
165
|
-
path.relative(cliCommon.targetPaths.rootDir, pkg.dir)
|
|
166
|
-
);
|
|
167
|
-
const repoField = pkg.packageJson.repository;
|
|
168
|
-
if (!repoField || typeof repoField === "string") {
|
|
169
|
-
const pkgEntries = Object.entries(pkg.packageJson);
|
|
170
|
-
pkgEntries.splice(
|
|
171
|
-
// Place it just above the backstage field
|
|
172
|
-
pkgEntries.findIndex(([name]) => name === "backstage"),
|
|
173
|
-
0,
|
|
174
|
-
[
|
|
175
|
-
"repository",
|
|
176
|
-
{
|
|
177
|
-
type: rootType,
|
|
178
|
-
url: rootUrl,
|
|
179
|
-
directory: expectedPath
|
|
180
|
-
}
|
|
181
|
-
]
|
|
182
|
-
);
|
|
183
|
-
pkg.packageJson = Object.fromEntries(pkgEntries);
|
|
184
|
-
pkg.changed = true;
|
|
185
|
-
return;
|
|
186
|
-
}
|
|
187
|
-
if (repoField.type !== rootType || repoField.url !== rootUrl) {
|
|
188
|
-
return;
|
|
189
|
-
}
|
|
190
|
-
if (repoField.directory !== expectedPath) {
|
|
191
|
-
repoField.directory = expectedPath;
|
|
192
|
-
pkg.changed = true;
|
|
193
|
-
}
|
|
194
|
-
};
|
|
195
|
-
}
|
|
196
|
-
function guessPluginId(role, pkgName) {
|
|
197
|
-
switch (role) {
|
|
198
|
-
case "frontend":
|
|
199
|
-
case "frontend-plugin":
|
|
200
|
-
return pkgName.match(/plugin-(.*)/)?.[1];
|
|
201
|
-
case "frontend-plugin-module":
|
|
202
|
-
return pkgName.match(/plugin-(.*)-module-/)?.[1];
|
|
203
|
-
case "backend-plugin":
|
|
204
|
-
return pkgName.match(/plugin-(.*)-backend$/)?.[1];
|
|
205
|
-
case "backend-plugin-module":
|
|
206
|
-
return pkgName.match(/plugin-(.*)-backend-module-/)?.[1];
|
|
207
|
-
case "common-library":
|
|
208
|
-
return pkgName.match(/plugin-(.*)-(?:common)$/)?.[1];
|
|
209
|
-
case "web-library":
|
|
210
|
-
return pkgName.match(/plugin-(.*)-(?:react|test-utils)/)?.[1];
|
|
211
|
-
case "node-library":
|
|
212
|
-
return pkgName.match(/plugin-(.*)-(?:node|backend)-?/)?.[1];
|
|
213
|
-
default:
|
|
214
|
-
throw new Error(
|
|
215
|
-
`Invalid 'backstage.role' field in "${pkgName}", got '${role}'`
|
|
216
|
-
);
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
function fixPluginId(pkg) {
|
|
220
|
-
const role = pkg.packageJson.backstage?.role;
|
|
221
|
-
if (!role) {
|
|
222
|
-
return;
|
|
223
|
-
}
|
|
224
|
-
if (role === "backend" || role === "frontend" || role === "cli") {
|
|
225
|
-
return;
|
|
226
|
-
}
|
|
227
|
-
const currentId = pkg.packageJson.backstage?.pluginId;
|
|
228
|
-
if (currentId !== void 0) {
|
|
229
|
-
if (typeof currentId !== "string" && currentId !== null) {
|
|
230
|
-
throw new Error(
|
|
231
|
-
`Invalid 'backstage.pluginId' field in "${pkg.packageJson.name}", must be a string`
|
|
232
|
-
);
|
|
233
|
-
}
|
|
234
|
-
return;
|
|
235
|
-
}
|
|
236
|
-
const guessedPluginId = guessPluginId(role, pkg.packageJson.name);
|
|
237
|
-
if (!guessedPluginId && (role === "frontend-plugin" || role === "frontend-plugin-module" || role === "backend-plugin" || role === "backend-plugin-module")) {
|
|
238
|
-
const path$1 = path.relative(
|
|
239
|
-
cliCommon.targetPaths.rootDir,
|
|
240
|
-
path.resolve(pkg.dir, "package.json")
|
|
241
|
-
);
|
|
242
|
-
const msg = `Failed to guess plugin ID for "${pkg.packageJson.name}", please set the 'backstage.pluginId' field manually in "${path$1}"`;
|
|
243
|
-
if (role.endsWith("module")) {
|
|
244
|
-
const suggestedRole = role.startsWith("frontend") ? "web-library" : "node-library";
|
|
245
|
-
throw new Error(
|
|
246
|
-
`${msg}. It is also possible that this package is not a module, and should use the '${suggestedRole}' role instead.`
|
|
247
|
-
);
|
|
248
|
-
} else {
|
|
249
|
-
throw new Error(msg);
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
if (guessedPluginId) {
|
|
253
|
-
pkg.packageJson.backstage = {
|
|
254
|
-
...pkg.packageJson.backstage,
|
|
255
|
-
pluginId: guessedPluginId
|
|
256
|
-
};
|
|
257
|
-
pkg.changed = true;
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
const backendPluginPackageNameByPluginId = new Map(
|
|
261
|
-
[
|
|
262
|
-
"app",
|
|
263
|
-
"auth",
|
|
264
|
-
"catalog",
|
|
265
|
-
"events",
|
|
266
|
-
"kubernetes",
|
|
267
|
-
"notifications",
|
|
268
|
-
"permission",
|
|
269
|
-
"scaffolder",
|
|
270
|
-
"search",
|
|
271
|
-
"signals",
|
|
272
|
-
"techdocs"
|
|
273
|
-
].map((pluginId) => [pluginId, `@backstage/plugin-${pluginId}-backend`])
|
|
274
|
-
);
|
|
275
|
-
const pluginPackageRoles = [
|
|
276
|
-
"frontend-plugin",
|
|
277
|
-
"backend-plugin",
|
|
278
|
-
"common-library",
|
|
279
|
-
"web-library",
|
|
280
|
-
"node-library"
|
|
281
|
-
];
|
|
282
|
-
function fixPluginPackages(pkg, repoPackages) {
|
|
283
|
-
const pkgBackstage = pkg.packageJson.backstage;
|
|
284
|
-
const role = pkgBackstage?.role;
|
|
285
|
-
if (!role) {
|
|
286
|
-
return;
|
|
287
|
-
}
|
|
288
|
-
if (role === "backend" || role === "frontend" || role === "cli") {
|
|
289
|
-
return;
|
|
290
|
-
}
|
|
291
|
-
const pluginId = pkgBackstage.pluginId;
|
|
292
|
-
if (!pluginId) {
|
|
293
|
-
if (role === "common-library" || role === "web-library" || role === "node-library" || role === "frontend-plugin-module") {
|
|
294
|
-
return;
|
|
295
|
-
}
|
|
296
|
-
throw new Error(
|
|
297
|
-
`Missing 'backstage.pluginId' field in "${pkg.packageJson.name}"`
|
|
298
|
-
);
|
|
299
|
-
}
|
|
300
|
-
if (role === "backend-plugin-module" || role === "frontend-plugin-module") {
|
|
301
|
-
const targetRole = role.replace("-module", "");
|
|
302
|
-
const pluginPkgName = repoPackages.find(
|
|
303
|
-
(p) => p.packageJson.backstage?.pluginId === pluginId && p.packageJson.backstage?.role === targetRole
|
|
304
|
-
)?.packageJson.name ?? backendPluginPackageNameByPluginId.get(pluginId);
|
|
305
|
-
if (!pluginPkgName) {
|
|
306
|
-
if (pkgBackstage.pluginPackage) {
|
|
307
|
-
return;
|
|
308
|
-
}
|
|
309
|
-
const path$1 = path.relative(
|
|
310
|
-
cliCommon.targetPaths.rootDir,
|
|
311
|
-
path.resolve(pkg.dir, "package.json")
|
|
312
|
-
);
|
|
313
|
-
const suggestedRole = role === "frontend-plugin-module" ? "web-library" : "node-library";
|
|
314
|
-
throw new Error(
|
|
315
|
-
`Failed to find plugin package for "${pkg.packageJson.name}", please declare the name of the plugin package that this package is a module for in the 'backstage.pluginPackage' field in "${path$1}". It is also possible that this package is not a module, and should use the '${suggestedRole}' role instead.`
|
|
316
|
-
);
|
|
317
|
-
}
|
|
318
|
-
if (pkgBackstage.pluginPackage !== pluginPkgName) {
|
|
319
|
-
pkgBackstage.pluginPackage = pluginPkgName;
|
|
320
|
-
pkg.changed = true;
|
|
321
|
-
}
|
|
322
|
-
} else {
|
|
323
|
-
let pluginPackages = repoPackages.filter(
|
|
324
|
-
(p) => p.packageJson.backstage?.pluginId === pluginId && pluginPackageRoles.includes(p.packageJson.backstage?.role)
|
|
325
|
-
).map((p) => p.packageJson.name).sort();
|
|
326
|
-
if (pluginPackages.length === 0) {
|
|
327
|
-
pluginPackages = void 0;
|
|
328
|
-
}
|
|
329
|
-
if (pkgBackstage.pluginPackages?.join(",") !== pluginPackages?.join(",")) {
|
|
330
|
-
pkgBackstage.pluginPackages = pluginPackages;
|
|
331
|
-
pkg.changed = true;
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
function fixPeerModules(pkg) {
|
|
336
|
-
const pkgBackstage = pkg.packageJson.backstage;
|
|
337
|
-
const role = pkgBackstage?.role;
|
|
338
|
-
if (!role) {
|
|
339
|
-
return;
|
|
340
|
-
}
|
|
341
|
-
const peerModules = pkgBackstage.peerModules;
|
|
342
|
-
if (peerModules === void 0) {
|
|
343
|
-
return;
|
|
344
|
-
}
|
|
345
|
-
const packagePath = path.relative(
|
|
346
|
-
cliCommon.targetPaths.rootDir,
|
|
347
|
-
path.resolve(pkg.dir, "package.json")
|
|
348
|
-
);
|
|
349
|
-
if (role !== "backend-plugin" && role !== "frontend-plugin") {
|
|
350
|
-
throw new Error(
|
|
351
|
-
`The 'backstage.peerModules' field in "${pkg.packageJson.name}" can only be used on plugin packages (backend-plugin or frontend-plugin), but package has role '${role}' in "${packagePath}"`
|
|
352
|
-
);
|
|
353
|
-
}
|
|
354
|
-
if (!Array.isArray(peerModules)) {
|
|
355
|
-
throw new Error(
|
|
356
|
-
`Invalid 'backstage.peerModules' field in "${pkg.packageJson.name}", must be an array of package names in "${packagePath}"`
|
|
357
|
-
);
|
|
358
|
-
}
|
|
359
|
-
for (const entry of peerModules) {
|
|
360
|
-
if (typeof entry !== "string" || entry.length === 0) {
|
|
361
|
-
throw new Error(
|
|
362
|
-
`Invalid entry in 'backstage.peerModules' field in "${pkg.packageJson.name}", all entries must be non-empty package name strings in "${packagePath}"`
|
|
363
|
-
);
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
var fix = async ({
|
|
368
|
-
args,
|
|
369
|
-
info
|
|
370
|
-
}) => {
|
|
371
|
-
const {
|
|
372
|
-
flags: { publish, check }
|
|
373
|
-
} = cleye.cli(
|
|
374
|
-
{
|
|
375
|
-
help: info,
|
|
376
|
-
booleanFlagNegation: true,
|
|
377
|
-
flags: {
|
|
378
|
-
publish: {
|
|
379
|
-
type: Boolean,
|
|
380
|
-
description: "Enable additional fixes that only apply when publishing packages"
|
|
381
|
-
},
|
|
382
|
-
check: {
|
|
383
|
-
type: Boolean,
|
|
384
|
-
description: "Fail if any packages would have been changed by the command"
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
},
|
|
388
|
-
void 0,
|
|
389
|
-
args
|
|
390
|
-
);
|
|
391
|
-
const packages = await readFixablePackages();
|
|
392
|
-
const fixRepositoryField = createRepositoryFieldFixer();
|
|
393
|
-
const fixers = [fixPackageExports, fixSideEffects];
|
|
394
|
-
if (publish) {
|
|
395
|
-
fixers.push(
|
|
396
|
-
fixRepositoryField,
|
|
397
|
-
fixPluginId,
|
|
398
|
-
fixPluginPackages,
|
|
399
|
-
fixPeerModules
|
|
400
|
-
);
|
|
401
|
-
}
|
|
402
|
-
for (const fixer of fixers) {
|
|
403
|
-
for (const pkg of packages) {
|
|
404
|
-
fixer(pkg, packages);
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
if (check) {
|
|
408
|
-
if (printPackageFixHint(packages)) {
|
|
409
|
-
process.exit(1);
|
|
410
|
-
}
|
|
411
|
-
} else {
|
|
412
|
-
await writeFixedPackages(packages);
|
|
413
|
-
}
|
|
414
|
-
};
|
|
415
|
-
|
|
416
|
-
exports.createRepositoryFieldFixer = createRepositoryFieldFixer;
|
|
417
|
-
exports.default = fix;
|
|
418
|
-
exports.fixPackageExports = fixPackageExports;
|
|
419
|
-
exports.fixPeerModules = fixPeerModules;
|
|
420
|
-
exports.fixPluginId = fixPluginId;
|
|
421
|
-
exports.fixPluginPackages = fixPluginPackages;
|
|
422
|
-
exports.fixSideEffects = fixSideEffects;
|
|
423
|
-
exports.printPackageFixHint = printPackageFixHint;
|
|
424
|
-
exports.readFixablePackages = readFixablePackages;
|
|
425
|
-
exports.writeFixedPackages = writeFixedPackages;
|
|
426
|
-
//# sourceMappingURL=fix.cjs.js.map
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var chalk = require('chalk');
|
|
6
|
-
var eslint = require('eslint');
|
|
7
|
-
var cleye = require('cleye');
|
|
8
|
-
var path = require('node:path');
|
|
9
|
-
var cliNode = require('@backstage/cli-node');
|
|
10
|
-
var cliCommon = require('@backstage/cli-common');
|
|
11
|
-
|
|
12
|
-
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
13
|
-
|
|
14
|
-
var chalk__default = /*#__PURE__*/_interopDefaultCompat(chalk);
|
|
15
|
-
|
|
16
|
-
var listDeprecations = async ({ args, info }) => {
|
|
17
|
-
const {
|
|
18
|
-
flags: { json }
|
|
19
|
-
} = cleye.cli(
|
|
20
|
-
{
|
|
21
|
-
help: info,
|
|
22
|
-
booleanFlagNegation: true,
|
|
23
|
-
flags: {
|
|
24
|
-
json: { type: Boolean, description: "Output as JSON" }
|
|
25
|
-
}
|
|
26
|
-
},
|
|
27
|
-
void 0,
|
|
28
|
-
args
|
|
29
|
-
);
|
|
30
|
-
const packages = await cliNode.PackageGraph.listTargetPackages();
|
|
31
|
-
const eslint$1 = new eslint.ESLint({
|
|
32
|
-
cwd: cliCommon.targetPaths.dir,
|
|
33
|
-
overrideConfig: {
|
|
34
|
-
plugins: ["deprecation"],
|
|
35
|
-
rules: {
|
|
36
|
-
"deprecation/deprecation": "error"
|
|
37
|
-
},
|
|
38
|
-
parserOptions: {
|
|
39
|
-
project: [cliCommon.targetPaths.resolveRoot("tsconfig.json")]
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
extensions: ["jsx", "ts", "tsx", "mjs", "cjs"]
|
|
43
|
-
});
|
|
44
|
-
const { stderr } = process;
|
|
45
|
-
if (stderr.isTTY) {
|
|
46
|
-
stderr.write("Initializing TypeScript...");
|
|
47
|
-
}
|
|
48
|
-
const deprecations = [];
|
|
49
|
-
for (const [index, pkg] of packages.entries()) {
|
|
50
|
-
const results = await eslint$1.lintFiles(pkg.dir);
|
|
51
|
-
for (const result of results) {
|
|
52
|
-
for (const message of result.messages) {
|
|
53
|
-
if (message.ruleId !== "deprecation/deprecation") {
|
|
54
|
-
continue;
|
|
55
|
-
}
|
|
56
|
-
const path$1 = path.relative(cliCommon.targetPaths.rootDir, result.filePath);
|
|
57
|
-
deprecations.push({
|
|
58
|
-
path: path$1,
|
|
59
|
-
message: message.message,
|
|
60
|
-
line: message.line,
|
|
61
|
-
column: message.column
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
if (stderr.isTTY) {
|
|
66
|
-
stderr.clearLine(0);
|
|
67
|
-
stderr.cursorTo(0);
|
|
68
|
-
stderr.write(`Scanning packages ${index + 1}/${packages.length}`);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
if (stderr.isTTY) {
|
|
72
|
-
stderr.clearLine(0);
|
|
73
|
-
stderr.cursorTo(0);
|
|
74
|
-
}
|
|
75
|
-
if (json) {
|
|
76
|
-
console.log(JSON.stringify(deprecations, null, 2));
|
|
77
|
-
} else {
|
|
78
|
-
for (const d of deprecations) {
|
|
79
|
-
const location = `${d.path}:${d.line}:${d.column}`;
|
|
80
|
-
const wrappedMessage = d.message.replace(/\r?\n\s*/g, " ");
|
|
81
|
-
console.log(`${location} - ${chalk__default.default.yellow(wrappedMessage)}`);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
if (deprecations.length > 0) {
|
|
85
|
-
process.exit(1);
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
exports.default = listDeprecations;
|
|
90
|
-
//# sourceMappingURL=list-deprecations.cjs.js.map
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var factory = require('../../wiring/factory.cjs.js');
|
|
6
|
-
|
|
7
|
-
var index = factory.createCliPlugin({
|
|
8
|
-
pluginId: "maintenance",
|
|
9
|
-
init: async (reg) => {
|
|
10
|
-
reg.addCommand({
|
|
11
|
-
path: ["repo", "fix"],
|
|
12
|
-
description: "Automatically fix packages in the project",
|
|
13
|
-
execute: { loader: () => import('./commands/repo/fix.cjs.js') }
|
|
14
|
-
});
|
|
15
|
-
reg.addCommand({
|
|
16
|
-
path: ["repo", "list-deprecations"],
|
|
17
|
-
description: "List deprecations",
|
|
18
|
-
execute: { loader: () => import('./commands/repo/list-deprecations.cjs.js') }
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
exports.default = index;
|
|
24
|
-
//# sourceMappingURL=index.cjs.js.map
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var cleye = require('cleye');
|
|
6
|
-
|
|
7
|
-
var packageExports = async ({ args, info }) => {
|
|
8
|
-
cleye.cli({ help: info, booleanFlagNegation: true }, void 0, args);
|
|
9
|
-
throw new Error(
|
|
10
|
-
"The `migrate package-exports` command has been removed, use `repo fix` instead."
|
|
11
|
-
);
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
exports.default = packageExports;
|
|
15
|
-
//# sourceMappingURL=packageExports.cjs.js.map
|
|
@@ -1,77 +0,0 @@
|
|
|
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 path = require('node:path');
|
|
8
|
-
var cliNode = require('@backstage/cli-node');
|
|
9
|
-
var cliCommon = require('@backstage/cli-common');
|
|
10
|
-
|
|
11
|
-
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
12
|
-
|
|
13
|
-
var fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
|
|
14
|
-
|
|
15
|
-
const PREFIX = `module.exports = require('@backstage/cli/config/eslint-factory')`;
|
|
16
|
-
var packageLintConfigs = async ({ args, info }) => {
|
|
17
|
-
cleye.cli({ help: info, booleanFlagNegation: true }, void 0, args);
|
|
18
|
-
const packages = await cliNode.PackageGraph.listTargetPackages();
|
|
19
|
-
const oldConfigs = [
|
|
20
|
-
require.resolve("@backstage/cli/config/eslint.js"),
|
|
21
|
-
require.resolve("@backstage/cli/config/eslint.backend.js")
|
|
22
|
-
];
|
|
23
|
-
const configPaths = new Array();
|
|
24
|
-
await Promise.all(
|
|
25
|
-
packages.map(async ({ dir, packageJson }) => {
|
|
26
|
-
const configPath = path.resolve(dir, ".eslintrc.js");
|
|
27
|
-
if (!await fs__default.default.pathExists(configPath)) {
|
|
28
|
-
console.log(`Skipping ${packageJson.name}, missing .eslintrc.js`);
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
let existingConfig;
|
|
32
|
-
try {
|
|
33
|
-
existingConfig = require(configPath);
|
|
34
|
-
} catch (error) {
|
|
35
|
-
console.log(
|
|
36
|
-
`Skipping ${packageJson.name}, failed to load .eslintrc.js, ${error}`
|
|
37
|
-
);
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
const extendsArray = existingConfig.extends ?? [];
|
|
41
|
-
const extendIndex = extendsArray.findIndex((p) => oldConfigs.includes(p));
|
|
42
|
-
if (extendIndex === -1) {
|
|
43
|
-
console.log(
|
|
44
|
-
`Skipping ${packageJson.name}, .eslintrc.js does not extend the legacy config`
|
|
45
|
-
);
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
extendsArray.splice(extendIndex, 1);
|
|
49
|
-
if (extendsArray.length === 0) {
|
|
50
|
-
delete existingConfig.extends;
|
|
51
|
-
}
|
|
52
|
-
if (Object.keys(existingConfig).length > 0) {
|
|
53
|
-
await fs__default.default.writeFile(
|
|
54
|
-
configPath,
|
|
55
|
-
`${PREFIX}(__dirname, ${JSON.stringify(existingConfig, null, 2)});
|
|
56
|
-
`
|
|
57
|
-
);
|
|
58
|
-
} else {
|
|
59
|
-
await fs__default.default.writeFile(configPath, `${PREFIX}(__dirname);
|
|
60
|
-
`);
|
|
61
|
-
}
|
|
62
|
-
configPaths.push(configPath);
|
|
63
|
-
})
|
|
64
|
-
);
|
|
65
|
-
let hasPrettier = false;
|
|
66
|
-
try {
|
|
67
|
-
require.resolve("prettier");
|
|
68
|
-
hasPrettier = true;
|
|
69
|
-
} catch {
|
|
70
|
-
}
|
|
71
|
-
if (hasPrettier) {
|
|
72
|
-
await cliCommon.runOutput(["prettier", "--write", ...configPaths]);
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
exports.default = packageLintConfigs;
|
|
77
|
-
//# sourceMappingURL=packageLintConfigs.cjs.js.map
|
|
@@ -1,57 +0,0 @@
|
|
|
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 path = require('node:path');
|
|
8
|
-
var getPackages = require('@manypkg/get-packages');
|
|
9
|
-
var cliNode = require('@backstage/cli-node');
|
|
10
|
-
var cliCommon = require('@backstage/cli-common');
|
|
11
|
-
|
|
12
|
-
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
13
|
-
|
|
14
|
-
var fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
|
|
15
|
-
|
|
16
|
-
var packageRole = async ({ args, info }) => {
|
|
17
|
-
cleye.cli({ help: info, booleanFlagNegation: true }, void 0, args);
|
|
18
|
-
const { packages } = await getPackages.getPackages(cliCommon.targetPaths.dir);
|
|
19
|
-
await Promise.all(
|
|
20
|
-
packages.map(async ({ dir, packageJson: pkg }) => {
|
|
21
|
-
const { name } = pkg;
|
|
22
|
-
const existingRole = cliNode.PackageRoles.getRoleFromPackage(pkg);
|
|
23
|
-
if (existingRole) {
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
const detectedRole = cliNode.PackageRoles.detectRoleFromPackage(pkg);
|
|
27
|
-
if (!detectedRole) {
|
|
28
|
-
console.error(`No role detected for package ${name}`);
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
console.log(`Detected package role of ${name} as ${detectedRole}`);
|
|
32
|
-
let newPkg = pkg;
|
|
33
|
-
const pkgKeys = Object.keys(pkg);
|
|
34
|
-
if (pkgKeys.includes("backstage")) {
|
|
35
|
-
newPkg.backstage = {
|
|
36
|
-
...newPkg.backstage,
|
|
37
|
-
role: detectedRole
|
|
38
|
-
};
|
|
39
|
-
} else {
|
|
40
|
-
const index = Math.max(
|
|
41
|
-
pkgKeys.indexOf("version"),
|
|
42
|
-
pkgKeys.indexOf("private"),
|
|
43
|
-
pkgKeys.indexOf("publishConfig")
|
|
44
|
-
) + 1 || pkgKeys.length;
|
|
45
|
-
const pkgEntries = Object.entries(pkg);
|
|
46
|
-
pkgEntries.splice(index, 0, ["backstage", { role: detectedRole }]);
|
|
47
|
-
newPkg = Object.fromEntries(pkgEntries);
|
|
48
|
-
}
|
|
49
|
-
await fs__default.default.writeJson(path.resolve(dir, "package.json"), newPkg, {
|
|
50
|
-
spaces: 2
|
|
51
|
-
});
|
|
52
|
-
})
|
|
53
|
-
);
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
exports.default = packageRole;
|
|
57
|
-
//# sourceMappingURL=packageRole.cjs.js.map
|