@backstage/cli 0.36.0-next.1 → 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 +110 -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 -10
- package/dist/wiring/CliInitializer.cjs.js +61 -20
- package/dist/wiring/CommandGraph.cjs.js +81 -23
- package/dist/wiring/discoverCliModules.cjs.js +44 -0
- package/package.json +27 -154
- package/dist/modules/build/commands/buildWorkspace.cjs.js +0 -24
- package/dist/modules/build/commands/package/build/command.cjs.js +0 -89
- package/dist/modules/build/commands/package/build/index.cjs.js +0 -8
- 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 -23
- package/dist/modules/build/commands/package/start/index.cjs.js +0 -8
- 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 -114
- package/dist/modules/build/commands/repo/clean.cjs.js +0 -41
- package/dist/modules/build/commands/repo/start.cjs.js +0 -150
- package/dist/modules/build/index.cjs.js +0 -192
- 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 -37
- 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 -62
- package/dist/modules/config/commands/print.cjs.js +0 -80
- package/dist/modules/config/commands/schema.cjs.js +0 -55
- package/dist/modules/config/commands/validate.cjs.js +0 -49
- 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 -115
- package/dist/modules/create-github-app/index.cjs.js +0 -27
- package/dist/modules/info/commands/info.cjs.js +0 -181
- package/dist/modules/info/index.cjs.js +0 -19
- package/dist/modules/lint/commands/package/lint.cjs.js +0 -46
- package/dist/modules/lint/commands/repo/lint.cjs.js +0 -212
- package/dist/modules/lint/index.cjs.js +0 -82
- package/dist/modules/lint/lib/optionsParser.cjs.js +0 -37
- package/dist/modules/maintenance/commands/repo/fix.cjs.js +0 -400
- package/dist/modules/maintenance/commands/repo/list-deprecations.cjs.js +0 -74
- package/dist/modules/maintenance/index.cjs.js +0 -42
- 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 -373
- package/dist/modules/migrate/commands/versions/migrate.cjs.js +0 -112
- package/dist/modules/migrate/index.cjs.js +0 -82
- 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 -60
- package/dist/modules/new/index.cjs.js +0 -68
- 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 -65
- package/dist/modules/test/commands/repo/test.cjs.js +0 -288
- package/dist/modules/test/index.cjs.js +0 -54
- package/dist/modules/translations/commands/export.cjs.js +0 -127
- package/dist/modules/translations/commands/import.cjs.js +0 -164
- 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 -156
- 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/lazy.cjs.js +0 -22
- 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,94 +0,0 @@
|
|
|
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 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
|
-
packagePaths: [cliCommon.targetPaths.resolveRoot("package.json")]
|
|
34
|
-
});
|
|
35
|
-
const source = configLoader.ConfigSources.default({
|
|
36
|
-
allowMissingDefaultConfig: true,
|
|
37
|
-
watch: Boolean(options.watch),
|
|
38
|
-
rootDir: cliCommon.targetPaths.rootDir,
|
|
39
|
-
argv: options.args.flatMap((t) => ["--config", path.resolve(targetDir, t)])
|
|
40
|
-
});
|
|
41
|
-
const appConfigs = await new Promise((resolve, reject) => {
|
|
42
|
-
async function loadConfigReaderLoop() {
|
|
43
|
-
let loaded = false;
|
|
44
|
-
try {
|
|
45
|
-
const abortController = new AbortController();
|
|
46
|
-
for await (const { configs } of source.readConfigData({
|
|
47
|
-
signal: abortController.signal
|
|
48
|
-
})) {
|
|
49
|
-
if (loaded) {
|
|
50
|
-
const newFrontendAppConfigs = schema.process(configs, {
|
|
51
|
-
visibility: ["frontend"],
|
|
52
|
-
withFilteredKeys: options.withFilteredKeys,
|
|
53
|
-
ignoreSchemaErrors: true
|
|
54
|
-
});
|
|
55
|
-
options.watch?.(newFrontendAppConfigs);
|
|
56
|
-
} else {
|
|
57
|
-
resolve(configs);
|
|
58
|
-
loaded = true;
|
|
59
|
-
if (!options.watch) {
|
|
60
|
-
abortController.abort();
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
} catch (error) {
|
|
65
|
-
if (loaded) {
|
|
66
|
-
console.error(`Failed to reload configuration, ${error}`);
|
|
67
|
-
} else {
|
|
68
|
-
reject(error);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
loadConfigReaderLoop();
|
|
73
|
-
});
|
|
74
|
-
const configurationLoadedMessage = appConfigs.length ? `Loaded config from ${appConfigs.map((c) => c.context).join(", ")}` : `No configuration files found, running without config`;
|
|
75
|
-
process.stderr.write(`${configurationLoadedMessage}
|
|
76
|
-
`);
|
|
77
|
-
const frontendAppConfigs = schema.process(appConfigs, {
|
|
78
|
-
visibility: ["frontend"],
|
|
79
|
-
withFilteredKeys: options.withFilteredKeys,
|
|
80
|
-
ignoreSchemaErrors: true
|
|
81
|
-
});
|
|
82
|
-
const frontendConfig = config.ConfigReader.fromConfigs(frontendAppConfigs);
|
|
83
|
-
const fullConfig = config.ConfigReader.fromConfigs(appConfigs);
|
|
84
|
-
return {
|
|
85
|
-
schema,
|
|
86
|
-
appConfigs,
|
|
87
|
-
frontendConfig,
|
|
88
|
-
frontendAppConfigs,
|
|
89
|
-
fullConfig
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
exports.loadCliConfig = loadCliConfig;
|
|
94
|
-
//# sourceMappingURL=config.cjs.js.map
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var path = require('node:path');
|
|
4
|
-
|
|
5
|
-
const defaultIndex = {
|
|
6
|
-
mount: ".",
|
|
7
|
-
path: "src/index.ts",
|
|
8
|
-
name: "index",
|
|
9
|
-
ext: ".ts"
|
|
10
|
-
};
|
|
11
|
-
const SCRIPT_EXTS = [".js", ".jsx", ".ts", ".tsx"];
|
|
12
|
-
function parseEntryPoint(mount, path$1) {
|
|
13
|
-
const ext = path.extname(path$1);
|
|
14
|
-
let name = mount;
|
|
15
|
-
if (name === ".") {
|
|
16
|
-
name = "index";
|
|
17
|
-
} else if (name.startsWith("./")) {
|
|
18
|
-
name = name.slice(2);
|
|
19
|
-
}
|
|
20
|
-
if (name.includes("/") && SCRIPT_EXTS.includes(ext)) {
|
|
21
|
-
throw new Error(`Mount point '${mount}' may not contain multiple slashes`);
|
|
22
|
-
}
|
|
23
|
-
return { mount, path: path$1, name, ext };
|
|
24
|
-
}
|
|
25
|
-
function readEntryPoints(pkg) {
|
|
26
|
-
const exp = pkg.exports;
|
|
27
|
-
if (typeof exp === "string") {
|
|
28
|
-
return [defaultIndex];
|
|
29
|
-
} else if (exp && typeof exp === "object" && !Array.isArray(exp)) {
|
|
30
|
-
const entryPoints = new Array();
|
|
31
|
-
for (const mount of Object.keys(exp)) {
|
|
32
|
-
const path = exp[mount];
|
|
33
|
-
if (typeof path !== "string") {
|
|
34
|
-
throw new Error(
|
|
35
|
-
`Exports field value must be a string, got '${JSON.stringify(path)}'`
|
|
36
|
-
);
|
|
37
|
-
}
|
|
38
|
-
if (process.env.EXPERIMENTAL_TRIM_NEXT_ENTRY && mount === "./next") {
|
|
39
|
-
continue;
|
|
40
|
-
}
|
|
41
|
-
entryPoints.push(parseEntryPoint(mount, path));
|
|
42
|
-
}
|
|
43
|
-
return entryPoints;
|
|
44
|
-
}
|
|
45
|
-
return [defaultIndex];
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
exports.readEntryPoints = readEntryPoints;
|
|
49
|
-
//# sourceMappingURL=entryPoints.cjs.js.map
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var errors = require('@backstage/errors');
|
|
4
|
-
|
|
5
|
-
const requestType = "@backstage/cli/channel/request";
|
|
6
|
-
const responseType = "@backstage/cli/channel/response";
|
|
7
|
-
class IpcServer {
|
|
8
|
-
#generation = 1;
|
|
9
|
-
#methods = /* @__PURE__ */ new Map();
|
|
10
|
-
addChild(child) {
|
|
11
|
-
const generation = this.#generation++;
|
|
12
|
-
const sendMessage = child.send?.bind(child);
|
|
13
|
-
if (!sendMessage) {
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
const messageListener = (request) => {
|
|
17
|
-
if (request.type !== requestType) {
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
const handler = this.#methods.get(request.method);
|
|
21
|
-
if (!handler) {
|
|
22
|
-
sendMessage({
|
|
23
|
-
type: responseType,
|
|
24
|
-
id: request.id,
|
|
25
|
-
error: {
|
|
26
|
-
name: "NotFoundError",
|
|
27
|
-
message: `No handler registered for method ${request.method}`
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
Promise.resolve().then(() => handler(request.body, { generation })).then(
|
|
33
|
-
(response) => sendMessage({
|
|
34
|
-
type: responseType,
|
|
35
|
-
id: request.id,
|
|
36
|
-
body: response
|
|
37
|
-
})
|
|
38
|
-
).catch(
|
|
39
|
-
(error) => sendMessage({
|
|
40
|
-
type: responseType,
|
|
41
|
-
id: request.id,
|
|
42
|
-
error: errors.serializeError(error)
|
|
43
|
-
})
|
|
44
|
-
);
|
|
45
|
-
};
|
|
46
|
-
child.addListener("message", messageListener);
|
|
47
|
-
child.addListener("exit", () => {
|
|
48
|
-
child.removeListener("message", messageListener);
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
registerMethod(method, handler) {
|
|
52
|
-
if (this.#methods.has(method)) {
|
|
53
|
-
throw new Error(`A handler is already registered for method ${method}`);
|
|
54
|
-
}
|
|
55
|
-
this.#methods.set(method, handler);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
exports.IpcServer = IpcServer;
|
|
60
|
-
//# sourceMappingURL=IpcServer.cjs.js.map
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
class ServerDataStore {
|
|
4
|
-
static bind(server) {
|
|
5
|
-
const store = /* @__PURE__ */ new Map();
|
|
6
|
-
server.registerMethod(
|
|
7
|
-
"DevDataStore.save",
|
|
8
|
-
async (request, { generation }) => {
|
|
9
|
-
const { key, data } = request;
|
|
10
|
-
if (!key) {
|
|
11
|
-
throw new Error("Key is required in DevDataStore.save");
|
|
12
|
-
}
|
|
13
|
-
const item = store.get(key);
|
|
14
|
-
if (!item) {
|
|
15
|
-
store.set(key, { generation, data });
|
|
16
|
-
return { saved: true };
|
|
17
|
-
}
|
|
18
|
-
if (item.generation > generation) {
|
|
19
|
-
return { saved: false };
|
|
20
|
-
}
|
|
21
|
-
store.set(key, { generation, data });
|
|
22
|
-
return { saved: true };
|
|
23
|
-
}
|
|
24
|
-
);
|
|
25
|
-
server.registerMethod(
|
|
26
|
-
"DevDataStore.load",
|
|
27
|
-
async (request) => {
|
|
28
|
-
const item = store.get(request.key);
|
|
29
|
-
return { loaded: Boolean(item), data: item?.data };
|
|
30
|
-
}
|
|
31
|
-
);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
exports.ServerDataStore = ServerDataStore;
|
|
36
|
-
//# sourceMappingURL=ServerDataStore.cjs.js.map
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
function createScriptOptionsParser(anyCmd, commandPath) {
|
|
4
|
-
let rootCmd = anyCmd;
|
|
5
|
-
while (rootCmd.parent) {
|
|
6
|
-
rootCmd = rootCmd.parent;
|
|
7
|
-
}
|
|
8
|
-
let targetCmd = rootCmd;
|
|
9
|
-
for (const name of commandPath) {
|
|
10
|
-
targetCmd = targetCmd?.commands.find((c) => c.name() === name);
|
|
11
|
-
}
|
|
12
|
-
if (!targetCmd) {
|
|
13
|
-
throw new Error(
|
|
14
|
-
`Could not find package command '${commandPath.join(" ")}'`
|
|
15
|
-
);
|
|
16
|
-
}
|
|
17
|
-
const cmd = targetCmd;
|
|
18
|
-
const expectedScript = `backstage-cli ${commandPath.join(" ")}`;
|
|
19
|
-
return (scriptStr) => {
|
|
20
|
-
if (!scriptStr || !scriptStr.startsWith(expectedScript)) {
|
|
21
|
-
return void 0;
|
|
22
|
-
}
|
|
23
|
-
const argsStr = scriptStr.slice(expectedScript.length).trim();
|
|
24
|
-
const currentOpts = cmd._optionValues;
|
|
25
|
-
const currentStore = cmd._storeOptionsAsProperties;
|
|
26
|
-
const result = {};
|
|
27
|
-
cmd._storeOptionsAsProperties = false;
|
|
28
|
-
cmd._optionValues = result;
|
|
29
|
-
cmd.parseOptions(argsStr.split(" "));
|
|
30
|
-
cmd._optionValues = currentOpts;
|
|
31
|
-
cmd._storeOptionsAsProperties = currentStore;
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
exports.createScriptOptionsParser = createScriptOptionsParser;
|
|
37
|
-
//# sourceMappingURL=optionsParser.cjs.js.map
|
|
@@ -1,235 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var chalk = require('chalk');
|
|
4
|
-
var fs = require('fs-extra');
|
|
5
|
-
var path = require('node:path');
|
|
6
|
-
var os = require('node:os');
|
|
7
|
-
var tar = require('tar');
|
|
8
|
-
var partition = require('lodash/partition');
|
|
9
|
-
var cliCommon = require('@backstage/cli-common');
|
|
10
|
-
var _package = require('../../../../packages/cli/package.json.cjs.js');
|
|
11
|
-
var packager = require('../builder/packager.cjs.js');
|
|
12
|
-
var types = require('../builder/types.cjs.js');
|
|
13
|
-
var productionPack = require('./productionPack.cjs.js');
|
|
14
|
-
var cliNode = require('@backstage/cli-node');
|
|
15
|
-
var typeDistProject = require('../typeDistProject.cjs.js');
|
|
16
|
-
|
|
17
|
-
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
18
|
-
|
|
19
|
-
function _interopNamespaceCompat(e) {
|
|
20
|
-
if (e && typeof e === 'object' && 'default' in e) return e;
|
|
21
|
-
var n = Object.create(null);
|
|
22
|
-
if (e) {
|
|
23
|
-
Object.keys(e).forEach(function (k) {
|
|
24
|
-
if (k !== 'default') {
|
|
25
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
26
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
27
|
-
enumerable: true,
|
|
28
|
-
get: function () { return e[k]; }
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
n.default = e;
|
|
34
|
-
return Object.freeze(n);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
var chalk__default = /*#__PURE__*/_interopDefaultCompat(chalk);
|
|
38
|
-
var fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
|
|
39
|
-
var tar__namespace = /*#__PURE__*/_interopNamespaceCompat(tar);
|
|
40
|
-
var partition__default = /*#__PURE__*/_interopDefaultCompat(partition);
|
|
41
|
-
|
|
42
|
-
const UNSAFE_PACKAGES = [
|
|
43
|
-
...Object.keys(_package.dependencies),
|
|
44
|
-
...Object.keys(_package.devDependencies)
|
|
45
|
-
];
|
|
46
|
-
function prefixLogFunc(prefix, out) {
|
|
47
|
-
return (data) => {
|
|
48
|
-
for (const line of data.toString("utf8").split(/\r?\n/)) {
|
|
49
|
-
process[out].write(`${prefix} ${line}
|
|
50
|
-
`);
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
async function createDistWorkspace(packageNames, options = {}) {
|
|
55
|
-
const targetDir = options.targetDir ?? await fs__default.default.mkdtemp(path.resolve(os.tmpdir(), "dist-workspace"));
|
|
56
|
-
const packages = await cliNode.PackageGraph.listTargetPackages();
|
|
57
|
-
const packageGraph = cliNode.PackageGraph.fromPackages(packages);
|
|
58
|
-
const targetNames = packageGraph.collectPackageNames(packageNames, (node) => {
|
|
59
|
-
if (node.packageJson.bundled) {
|
|
60
|
-
return void 0;
|
|
61
|
-
}
|
|
62
|
-
return node.publishedLocalDependencies.keys();
|
|
63
|
-
});
|
|
64
|
-
const targets = Array.from(targetNames).map((name) => packageGraph.get(name));
|
|
65
|
-
if (options.buildDependencies) {
|
|
66
|
-
const exclude = options.buildExcludes ?? [];
|
|
67
|
-
const configPaths = options.configPaths ?? [];
|
|
68
|
-
const toBuild = new Set(
|
|
69
|
-
targets.map((_) => _.name).filter((name) => !exclude.includes(name))
|
|
70
|
-
);
|
|
71
|
-
const standardBuilds = new Array();
|
|
72
|
-
const customBuild = new Array();
|
|
73
|
-
for (const pkg of packages) {
|
|
74
|
-
if (!toBuild.has(pkg.packageJson.name)) {
|
|
75
|
-
continue;
|
|
76
|
-
}
|
|
77
|
-
const role = pkg.packageJson.backstage?.role;
|
|
78
|
-
if (!role) {
|
|
79
|
-
console.warn(
|
|
80
|
-
`Building ${pkg.packageJson.name} separately because it has no role`
|
|
81
|
-
);
|
|
82
|
-
customBuild.push({ dir: pkg.dir, name: pkg.packageJson.name });
|
|
83
|
-
continue;
|
|
84
|
-
}
|
|
85
|
-
const buildScript = pkg.packageJson.scripts?.build;
|
|
86
|
-
if (!buildScript) {
|
|
87
|
-
customBuild.push({ dir: pkg.dir, name: pkg.packageJson.name });
|
|
88
|
-
continue;
|
|
89
|
-
}
|
|
90
|
-
if (!buildScript.startsWith("backstage-cli package build")) {
|
|
91
|
-
console.warn(
|
|
92
|
-
`Building ${pkg.packageJson.name} separately because it has a custom build script, '${buildScript}'`
|
|
93
|
-
);
|
|
94
|
-
customBuild.push({ dir: pkg.dir, name: pkg.packageJson.name });
|
|
95
|
-
continue;
|
|
96
|
-
}
|
|
97
|
-
if (cliNode.PackageRoles.getRoleInfo(role).output.includes("bundle")) {
|
|
98
|
-
console.warn(
|
|
99
|
-
`Building ${pkg.packageJson.name} separately because it is a bundled package`
|
|
100
|
-
);
|
|
101
|
-
const args = buildScript.includes("--config") ? [] : configPaths.map((p) => ["--config", p]).flat();
|
|
102
|
-
customBuild.push({ dir: pkg.dir, name: pkg.packageJson.name, args });
|
|
103
|
-
continue;
|
|
104
|
-
}
|
|
105
|
-
const outputs = packager.getOutputsForRole(role);
|
|
106
|
-
outputs.delete(types.Output.types);
|
|
107
|
-
if (outputs.size > 0) {
|
|
108
|
-
standardBuilds.push({
|
|
109
|
-
targetDir: pkg.dir,
|
|
110
|
-
packageJson: pkg.packageJson,
|
|
111
|
-
outputs,
|
|
112
|
-
logPrefix: `${chalk__default.default.cyan(
|
|
113
|
-
path.relative(cliCommon.targetPaths.rootDir, pkg.dir)
|
|
114
|
-
)}: `,
|
|
115
|
-
minify: options.minify,
|
|
116
|
-
workspacePackages: packages
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
await packager.buildPackages(standardBuilds);
|
|
121
|
-
if (customBuild.length > 0) {
|
|
122
|
-
await cliNode.runConcurrentTasks({
|
|
123
|
-
items: customBuild,
|
|
124
|
-
worker: async ({ name, dir, args }) => {
|
|
125
|
-
await cliCommon.run(["yarn", "run", "build", ...args || []], {
|
|
126
|
-
cwd: dir,
|
|
127
|
-
onStdout: prefixLogFunc(`${name}: `, "stdout"),
|
|
128
|
-
onStderr: prefixLogFunc(`${name}: `, "stderr")
|
|
129
|
-
}).waitForExit();
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
await moveToDistWorkspace(
|
|
135
|
-
targetDir,
|
|
136
|
-
targets,
|
|
137
|
-
Boolean(options.alwaysPack),
|
|
138
|
-
Boolean(options.enableFeatureDetection)
|
|
139
|
-
);
|
|
140
|
-
const files = options.files ?? ["yarn.lock", "package.json"];
|
|
141
|
-
for (const file of files) {
|
|
142
|
-
const src = typeof file === "string" ? file : file.src;
|
|
143
|
-
const dest = typeof file === "string" ? file : file.dest;
|
|
144
|
-
await fs__default.default.copy(cliCommon.targetPaths.resolveRoot(src), path.resolve(targetDir, dest));
|
|
145
|
-
}
|
|
146
|
-
if (options.skeleton) {
|
|
147
|
-
const skeletonFiles = targets.map((target) => {
|
|
148
|
-
const dir = path.relative(cliCommon.targetPaths.rootDir, target.dir);
|
|
149
|
-
return path.join(dir, "package.json");
|
|
150
|
-
}).sort();
|
|
151
|
-
await tar__namespace.create(
|
|
152
|
-
{
|
|
153
|
-
file: path.resolve(targetDir, options.skeleton),
|
|
154
|
-
cwd: targetDir,
|
|
155
|
-
portable: true,
|
|
156
|
-
noMtime: true,
|
|
157
|
-
gzip: options.skeleton.endsWith(".gz")
|
|
158
|
-
},
|
|
159
|
-
skeletonFiles
|
|
160
|
-
);
|
|
161
|
-
}
|
|
162
|
-
return targetDir;
|
|
163
|
-
}
|
|
164
|
-
const FAST_PACK_SCRIPTS = [
|
|
165
|
-
void 0,
|
|
166
|
-
"backstage-cli prepack",
|
|
167
|
-
"backstage-cli package prepack"
|
|
168
|
-
];
|
|
169
|
-
async function moveToDistWorkspace(workspaceDir, localPackages, alwaysPack, enableFeatureDetection) {
|
|
170
|
-
const [fastPackPackages, slowPackPackages] = partition__default.default(
|
|
171
|
-
localPackages,
|
|
172
|
-
(pkg) => !alwaysPack && FAST_PACK_SCRIPTS.includes(pkg.packageJson.scripts?.prepack)
|
|
173
|
-
);
|
|
174
|
-
const featureDetectionProject = fastPackPackages.length > 0 && enableFeatureDetection ? await typeDistProject.createTypeDistProject() : void 0;
|
|
175
|
-
await Promise.all(
|
|
176
|
-
fastPackPackages.map(async (target) => {
|
|
177
|
-
console.log(`Moving ${target.name} into dist workspace`);
|
|
178
|
-
const outputDir = path.relative(cliCommon.targetPaths.rootDir, target.dir);
|
|
179
|
-
const absoluteOutputPath = path.resolve(workspaceDir, outputDir);
|
|
180
|
-
await productionPack.productionPack({
|
|
181
|
-
packageDir: target.dir,
|
|
182
|
-
targetDir: absoluteOutputPath,
|
|
183
|
-
featureDetectionProject
|
|
184
|
-
});
|
|
185
|
-
})
|
|
186
|
-
);
|
|
187
|
-
async function pack(target, archive) {
|
|
188
|
-
console.log(`Repacking ${target.name} into dist workspace`);
|
|
189
|
-
const archivePath = path.resolve(workspaceDir, archive);
|
|
190
|
-
await cliCommon.run(["yarn", "pack", "--filename", archivePath], {
|
|
191
|
-
cwd: target.dir
|
|
192
|
-
}).waitForExit();
|
|
193
|
-
const outputDir = path.relative(cliCommon.targetPaths.rootDir, target.dir);
|
|
194
|
-
const absoluteOutputPath = path.resolve(workspaceDir, outputDir);
|
|
195
|
-
await fs__default.default.ensureDir(absoluteOutputPath);
|
|
196
|
-
await tar__namespace.extract({
|
|
197
|
-
file: archivePath,
|
|
198
|
-
cwd: absoluteOutputPath,
|
|
199
|
-
strip: 1
|
|
200
|
-
});
|
|
201
|
-
await fs__default.default.remove(archivePath);
|
|
202
|
-
if (target.packageJson.bundled) {
|
|
203
|
-
const pkgJson = await fs__default.default.readJson(
|
|
204
|
-
path.resolve(absoluteOutputPath, "package.json")
|
|
205
|
-
);
|
|
206
|
-
delete pkgJson.dependencies;
|
|
207
|
-
delete pkgJson.devDependencies;
|
|
208
|
-
delete pkgJson.peerDependencies;
|
|
209
|
-
delete pkgJson.optionalDependencies;
|
|
210
|
-
await fs__default.default.writeJson(
|
|
211
|
-
path.resolve(absoluteOutputPath, "package.json"),
|
|
212
|
-
pkgJson,
|
|
213
|
-
{
|
|
214
|
-
spaces: 2
|
|
215
|
-
}
|
|
216
|
-
);
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
const [unsafePackages, safePackages] = partition__default.default(
|
|
220
|
-
slowPackPackages,
|
|
221
|
-
(p) => UNSAFE_PACKAGES.includes(p.name)
|
|
222
|
-
);
|
|
223
|
-
for (const target of unsafePackages) {
|
|
224
|
-
await pack(target, `temp-package.tgz`);
|
|
225
|
-
}
|
|
226
|
-
await cliNode.runConcurrentTasks({
|
|
227
|
-
items: safePackages.map((target, index) => ({ target, index })),
|
|
228
|
-
worker: async ({ target, index }) => {
|
|
229
|
-
await pack(target, `temp-package-${index}.tgz`);
|
|
230
|
-
}
|
|
231
|
-
});
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
exports.createDistWorkspace = createDistWorkspace;
|
|
235
|
-
//# sourceMappingURL=createDistWorkspace.cjs.js.map
|
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var fs = require('fs-extra');
|
|
4
|
-
var npmPackList = require('npm-packlist');
|
|
5
|
-
var path = require('node:path');
|
|
6
|
-
var entryPoints = require('../entryPoints.cjs.js');
|
|
7
|
-
var typeDistProject = require('../typeDistProject.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
|
-
var npmPackList__default = /*#__PURE__*/_interopDefaultCompat(npmPackList);
|
|
13
|
-
|
|
14
|
-
const PKG_PATH = "package.json";
|
|
15
|
-
const PKG_BACKUP_PATH = "package.json-prepack";
|
|
16
|
-
const SKIPPED_KEYS = ["access", "registry", "tag"];
|
|
17
|
-
const SCRIPT_EXTS = [".js", ".jsx", ".ts", ".tsx"];
|
|
18
|
-
async function productionPack(options) {
|
|
19
|
-
const { packageDir, targetDir } = options;
|
|
20
|
-
const pkgPath = path.resolve(packageDir, PKG_PATH);
|
|
21
|
-
const pkgContent = await fs__default.default.readFile(pkgPath, "utf8");
|
|
22
|
-
const pkg = JSON.parse(pkgContent);
|
|
23
|
-
if (!targetDir) {
|
|
24
|
-
await fs__default.default.writeFile(PKG_BACKUP_PATH, pkgContent);
|
|
25
|
-
}
|
|
26
|
-
await rewriteEntryPoints(pkg, packageDir, options.featureDetectionProject);
|
|
27
|
-
const publishConfig = pkg.publishConfig ?? {};
|
|
28
|
-
for (const key of Object.keys(publishConfig)) {
|
|
29
|
-
if (!SKIPPED_KEYS.includes(key)) {
|
|
30
|
-
pkg[key] = publishConfig[key];
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
if (pkg.bundled) {
|
|
34
|
-
delete pkg.dependencies;
|
|
35
|
-
delete pkg.devDependencies;
|
|
36
|
-
delete pkg.peerDependencies;
|
|
37
|
-
delete pkg.optionalDependencies;
|
|
38
|
-
}
|
|
39
|
-
if (targetDir) {
|
|
40
|
-
const filePaths = await npmPackList__default.default({
|
|
41
|
-
path: packageDir,
|
|
42
|
-
// This makes sure we use the updated package.json when listing files
|
|
43
|
-
packageJsonCache: /* @__PURE__ */ new Map([
|
|
44
|
-
[path.resolve(packageDir, PKG_PATH), pkg]
|
|
45
|
-
])
|
|
46
|
-
// Seems like this parameter type is wrong,
|
|
47
|
-
});
|
|
48
|
-
await fs__default.default.ensureDir(targetDir);
|
|
49
|
-
for (const filePath of filePaths.sort()) {
|
|
50
|
-
const target = path.resolve(targetDir, filePath);
|
|
51
|
-
if (filePath === PKG_PATH) {
|
|
52
|
-
await fs__default.default.writeJson(target, pkg, { encoding: "utf8", spaces: 2 });
|
|
53
|
-
} else {
|
|
54
|
-
await fs__default.default.copy(path.resolve(packageDir, filePath), target);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
} else {
|
|
58
|
-
await fs__default.default.writeJson(pkgPath, pkg, { encoding: "utf8", spaces: 2 });
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
async function revertProductionPack(packageDir) {
|
|
62
|
-
try {
|
|
63
|
-
await fs__default.default.move(PKG_BACKUP_PATH, PKG_PATH, { overwrite: true });
|
|
64
|
-
const pkg = await fs__default.default.readJson(PKG_PATH);
|
|
65
|
-
const entryPoints$1 = entryPoints.readEntryPoints(pkg);
|
|
66
|
-
for (const entryPoint of entryPoints$1) {
|
|
67
|
-
if (entryPoint.mount !== "." && SCRIPT_EXTS.includes(entryPoint.ext)) {
|
|
68
|
-
await fs__default.default.remove(path.resolve(packageDir, entryPoint.name));
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
} catch (error) {
|
|
72
|
-
console.warn(
|
|
73
|
-
`Failed to restore package.json, ${error}. Your package will be fine but you may have ended up with some garbage in the repo.`
|
|
74
|
-
);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
const EXPORT_MAP = {
|
|
78
|
-
import: ".esm.js",
|
|
79
|
-
require: ".cjs.js",
|
|
80
|
-
types: ".d.ts"
|
|
81
|
-
};
|
|
82
|
-
async function rewriteEntryPoints(pkg, packageDir, featureDetectionProject) {
|
|
83
|
-
const distPath = path.resolve(packageDir, "dist");
|
|
84
|
-
if (!await fs__default.default.pathExists(distPath)) {
|
|
85
|
-
return void 0;
|
|
86
|
-
}
|
|
87
|
-
const distFiles = await fs__default.default.readdir(distPath);
|
|
88
|
-
const outputExports = {};
|
|
89
|
-
const entryPoints$1 = entryPoints.readEntryPoints(pkg);
|
|
90
|
-
if (pkg.typesVersions) {
|
|
91
|
-
pkg.typesVersions = void 0;
|
|
92
|
-
}
|
|
93
|
-
for (const entryPoint of entryPoints$1) {
|
|
94
|
-
if (!SCRIPT_EXTS.includes(entryPoint.ext)) {
|
|
95
|
-
outputExports[entryPoint.mount] = entryPoint.path.replace(
|
|
96
|
-
/^(\.\/)?src\//,
|
|
97
|
-
"./dist/"
|
|
98
|
-
);
|
|
99
|
-
continue;
|
|
100
|
-
}
|
|
101
|
-
let exp = {};
|
|
102
|
-
for (const [key, ext] of Object.entries(EXPORT_MAP)) {
|
|
103
|
-
const name = `${entryPoint.name}${ext}`;
|
|
104
|
-
if (distFiles.includes(name)) {
|
|
105
|
-
exp[key] = `./${path.posix.join(`dist`, name)}`;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
if (exp.types) {
|
|
109
|
-
if (!pkg.typesVersions) {
|
|
110
|
-
pkg.typesVersions = { "*": {} };
|
|
111
|
-
}
|
|
112
|
-
if (entryPoint.name !== "index") {
|
|
113
|
-
pkg.typesVersions["*"][entryPoint.name] = [
|
|
114
|
-
`dist/${entryPoint.name}.d.ts`
|
|
115
|
-
];
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
exp.default = exp.require ?? exp.import;
|
|
119
|
-
if (exp.types && featureDetectionProject) {
|
|
120
|
-
const defaultFeatureType = pkg.backstage?.role && typeDistProject.getEntryPointDefaultFeatureType(
|
|
121
|
-
pkg.backstage?.role,
|
|
122
|
-
packageDir,
|
|
123
|
-
featureDetectionProject,
|
|
124
|
-
exp.types
|
|
125
|
-
);
|
|
126
|
-
if (defaultFeatureType) {
|
|
127
|
-
exp = { backstage: defaultFeatureType, ...exp };
|
|
128
|
-
pkg.backstage = pkg.backstage ?? {};
|
|
129
|
-
pkg.backstage.features = pkg.backstage.features ?? {};
|
|
130
|
-
pkg.backstage.features[entryPoint.mount] = defaultFeatureType;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
if (entryPoint.mount === ".") {
|
|
134
|
-
if (exp.default) {
|
|
135
|
-
pkg.main = exp.default;
|
|
136
|
-
}
|
|
137
|
-
if (exp.import) {
|
|
138
|
-
pkg.module = exp.import;
|
|
139
|
-
}
|
|
140
|
-
if (exp.types) {
|
|
141
|
-
pkg.types = exp.types;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
if (Object.keys(exp).length > 0) {
|
|
145
|
-
outputExports[entryPoint.mount] = exp;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
if (pkg.typesVersions?.["*"]) {
|
|
149
|
-
pkg.typesVersions["*"]["package.json"] = ["package.json"];
|
|
150
|
-
}
|
|
151
|
-
if (pkg.exports) {
|
|
152
|
-
pkg.exports = outputExports;
|
|
153
|
-
pkg.exports["./package.json"] = "./package.json";
|
|
154
|
-
}
|
|
155
|
-
return void 0;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
exports.productionPack = productionPack;
|
|
159
|
-
exports.revertProductionPack = revertProductionPack;
|
|
160
|
-
//# sourceMappingURL=productionPack.cjs.js.map
|