@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,212 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var chalk = require('chalk');
|
|
4
|
-
var fs = require('fs-extra');
|
|
5
|
-
var crypto = require('node:crypto');
|
|
6
|
-
var path = require('node:path');
|
|
7
|
-
var cliNode = require('@backstage/cli-node');
|
|
8
|
-
var cliCommon = require('@backstage/cli-common');
|
|
9
|
-
var optionsParser = require('../../lib/optionsParser.cjs.js');
|
|
10
|
-
|
|
11
|
-
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
12
|
-
|
|
13
|
-
var chalk__default = /*#__PURE__*/_interopDefaultCompat(chalk);
|
|
14
|
-
var fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
|
|
15
|
-
|
|
16
|
-
function depCount(pkg) {
|
|
17
|
-
const deps = pkg.dependencies ? Object.keys(pkg.dependencies).length : 0;
|
|
18
|
-
const devDeps = pkg.devDependencies ? Object.keys(pkg.devDependencies).length : 0;
|
|
19
|
-
return deps + devDeps;
|
|
20
|
-
}
|
|
21
|
-
async function command(opts, cmd) {
|
|
22
|
-
let packages = await cliNode.PackageGraph.listTargetPackages();
|
|
23
|
-
const cache = cliNode.SuccessCache.create({
|
|
24
|
-
name: "lint",
|
|
25
|
-
basePath: opts.successCacheDir
|
|
26
|
-
});
|
|
27
|
-
const cacheContext = opts.successCache ? {
|
|
28
|
-
entries: await cache.read(),
|
|
29
|
-
lockfile: await cliNode.Lockfile.load(cliCommon.targetPaths.resolveRoot("yarn.lock"))
|
|
30
|
-
} : void 0;
|
|
31
|
-
if (opts.since) {
|
|
32
|
-
const graph = cliNode.PackageGraph.fromPackages(packages);
|
|
33
|
-
packages = await graph.listChangedPackages({
|
|
34
|
-
ref: opts.since,
|
|
35
|
-
analyzeLockfile: true
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
packages.sort((a, b) => depCount(b.packageJson) - depCount(a.packageJson));
|
|
39
|
-
if (opts.format === "eslint-formatter-friendly") {
|
|
40
|
-
process.chdir(cliCommon.targetPaths.rootDir);
|
|
41
|
-
}
|
|
42
|
-
if (!process.env.FORCE_COLOR) {
|
|
43
|
-
process.env.FORCE_COLOR = "1";
|
|
44
|
-
}
|
|
45
|
-
const parseLintScript = optionsParser.createScriptOptionsParser(cmd, ["package", "lint"]);
|
|
46
|
-
const items = await Promise.all(
|
|
47
|
-
packages.map(async (pkg) => {
|
|
48
|
-
const lintOptions = parseLintScript(pkg.packageJson.scripts?.lint);
|
|
49
|
-
const base = {
|
|
50
|
-
fullDir: pkg.dir,
|
|
51
|
-
relativeDir: path.relative(cliCommon.targetPaths.rootDir, pkg.dir),
|
|
52
|
-
lintOptions,
|
|
53
|
-
parentHash: void 0
|
|
54
|
-
};
|
|
55
|
-
if (!cacheContext) {
|
|
56
|
-
return base;
|
|
57
|
-
}
|
|
58
|
-
const hash = crypto.createHash("sha1");
|
|
59
|
-
hash.update(
|
|
60
|
-
cacheContext.lockfile.getDependencyTreeHash(pkg.packageJson.name)
|
|
61
|
-
);
|
|
62
|
-
hash.update("\0");
|
|
63
|
-
hash.update(JSON.stringify(lintOptions ?? {}));
|
|
64
|
-
hash.update("\0");
|
|
65
|
-
hash.update(process.version);
|
|
66
|
-
hash.update("\0");
|
|
67
|
-
hash.update("v1");
|
|
68
|
-
return {
|
|
69
|
-
...base,
|
|
70
|
-
parentHash: hash.digest("hex")
|
|
71
|
-
};
|
|
72
|
-
})
|
|
73
|
-
);
|
|
74
|
-
const { results: resultsList } = await cliNode.runWorkerQueueThreads({
|
|
75
|
-
items: items.filter((item) => item.lintOptions),
|
|
76
|
-
// Filter out packages without lint script
|
|
77
|
-
context: {
|
|
78
|
-
fix: Boolean(opts.fix),
|
|
79
|
-
format: opts.format,
|
|
80
|
-
shouldCache: Boolean(cacheContext),
|
|
81
|
-
maxWarnings: opts.maxWarnings ?? -1,
|
|
82
|
-
successCache: cacheContext?.entries,
|
|
83
|
-
rootDir: cliCommon.targetPaths.rootDir
|
|
84
|
-
},
|
|
85
|
-
workerFactory: async ({
|
|
86
|
-
fix,
|
|
87
|
-
format,
|
|
88
|
-
shouldCache,
|
|
89
|
-
successCache,
|
|
90
|
-
rootDir,
|
|
91
|
-
maxWarnings
|
|
92
|
-
}) => {
|
|
93
|
-
const { ESLint } = require("eslint");
|
|
94
|
-
const crypto = require("node:crypto");
|
|
95
|
-
const globby = require("globby");
|
|
96
|
-
const { readFile } = require("node:fs/promises");
|
|
97
|
-
const workerPath = require("node:path");
|
|
98
|
-
return async ({
|
|
99
|
-
fullDir,
|
|
100
|
-
relativeDir,
|
|
101
|
-
parentHash
|
|
102
|
-
}) => {
|
|
103
|
-
process.cwd = () => fullDir;
|
|
104
|
-
const start = Date.now();
|
|
105
|
-
const eslint = new ESLint({
|
|
106
|
-
cwd: fullDir,
|
|
107
|
-
fix,
|
|
108
|
-
extensions: ["js", "jsx", "ts", "tsx", "mjs", "cjs"]
|
|
109
|
-
});
|
|
110
|
-
let sha = void 0;
|
|
111
|
-
if (shouldCache) {
|
|
112
|
-
const result = await globby(relativeDir, {
|
|
113
|
-
gitignore: true,
|
|
114
|
-
onlyFiles: true,
|
|
115
|
-
cwd: rootDir
|
|
116
|
-
});
|
|
117
|
-
const hash = crypto.createHash("sha1");
|
|
118
|
-
hash.update(parentHash);
|
|
119
|
-
hash.update("\0");
|
|
120
|
-
for (const path of result.sort()) {
|
|
121
|
-
const absPath = workerPath.resolve(rootDir, path);
|
|
122
|
-
const pathInPackage = workerPath.relative(fullDir, absPath);
|
|
123
|
-
if (await eslint.isPathIgnored(pathInPackage)) {
|
|
124
|
-
continue;
|
|
125
|
-
}
|
|
126
|
-
hash.update(pathInPackage);
|
|
127
|
-
hash.update("\0");
|
|
128
|
-
hash.update(await readFile(absPath));
|
|
129
|
-
hash.update("\0");
|
|
130
|
-
hash.update(
|
|
131
|
-
JSON.stringify(
|
|
132
|
-
await eslint.calculateConfigForFile(pathInPackage)
|
|
133
|
-
).replaceAll(rootDir, "")
|
|
134
|
-
);
|
|
135
|
-
hash.update("\0");
|
|
136
|
-
}
|
|
137
|
-
sha = await hash.digest("hex");
|
|
138
|
-
if (successCache?.has(sha)) {
|
|
139
|
-
console.log(`Skipped ${relativeDir} due to cache hit`);
|
|
140
|
-
return { relativeDir, sha, failed: false };
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
const formatter = await eslint.loadFormatter(format);
|
|
144
|
-
const results = await eslint.lintFiles(["."]);
|
|
145
|
-
const count = String(results.length).padStart(3);
|
|
146
|
-
const time = ((Date.now() - start) / 1e3).toFixed(2);
|
|
147
|
-
console.log(`Checked ${count} files in ${relativeDir} ${time}s`);
|
|
148
|
-
if (fix) {
|
|
149
|
-
await ESLint.outputFixes(results);
|
|
150
|
-
}
|
|
151
|
-
const ignoreWarnings = +maxWarnings === -1;
|
|
152
|
-
const resultText = formatter.format(results);
|
|
153
|
-
const failed2 = results.some((r) => r.errorCount > 0) || !ignoreWarnings && results.reduce((current, next) => current + next.warningCount, 0) > maxWarnings;
|
|
154
|
-
return {
|
|
155
|
-
relativeDir,
|
|
156
|
-
resultText,
|
|
157
|
-
failed: failed2,
|
|
158
|
-
sha
|
|
159
|
-
};
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
});
|
|
163
|
-
const outputSuccessCache = [];
|
|
164
|
-
const jsonResults = [];
|
|
165
|
-
let errorOutput = "";
|
|
166
|
-
let failed = false;
|
|
167
|
-
for (const {
|
|
168
|
-
relativeDir,
|
|
169
|
-
resultText,
|
|
170
|
-
failed: runFailed,
|
|
171
|
-
sha
|
|
172
|
-
} of resultsList) {
|
|
173
|
-
if (runFailed) {
|
|
174
|
-
console.log(chalk__default.default.red(`Lint failed in ${relativeDir}`));
|
|
175
|
-
failed = true;
|
|
176
|
-
if (resultText) {
|
|
177
|
-
if (opts.outputFile) {
|
|
178
|
-
if (opts.format === "json") {
|
|
179
|
-
jsonResults.push(resultText);
|
|
180
|
-
} else {
|
|
181
|
-
errorOutput += `${resultText}
|
|
182
|
-
`;
|
|
183
|
-
}
|
|
184
|
-
} else {
|
|
185
|
-
console.log();
|
|
186
|
-
console.log(resultText.trimStart());
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
} else if (sha) {
|
|
190
|
-
outputSuccessCache.push(sha);
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
if (opts.format === "json") {
|
|
194
|
-
let mergedJsonResults = [];
|
|
195
|
-
for (const jsonResult of jsonResults) {
|
|
196
|
-
mergedJsonResults = mergedJsonResults.concat(JSON.parse(jsonResult));
|
|
197
|
-
}
|
|
198
|
-
errorOutput = JSON.stringify(mergedJsonResults, null, 2);
|
|
199
|
-
}
|
|
200
|
-
if (opts.outputFile && errorOutput) {
|
|
201
|
-
await fs__default.default.writeFile(cliCommon.targetPaths.resolveRoot(opts.outputFile), errorOutput);
|
|
202
|
-
}
|
|
203
|
-
if (cacheContext) {
|
|
204
|
-
await cache.write(outputSuccessCache);
|
|
205
|
-
}
|
|
206
|
-
if (failed) {
|
|
207
|
-
process.exit(1);
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
exports.command = command;
|
|
212
|
-
//# sourceMappingURL=lint.cjs.js.map
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var factory = require('../../wiring/factory.cjs.js');
|
|
6
|
-
var commander = require('commander');
|
|
7
|
-
var lazy = require('../../wiring/lazy.cjs.js');
|
|
8
|
-
|
|
9
|
-
function registerPackageLintCommand(command) {
|
|
10
|
-
command.arguments("[directories...]");
|
|
11
|
-
command.option("--fix", "Attempt to automatically fix violations");
|
|
12
|
-
command.option(
|
|
13
|
-
"--format <format>",
|
|
14
|
-
"Lint report output format",
|
|
15
|
-
"eslint-formatter-friendly"
|
|
16
|
-
);
|
|
17
|
-
command.option(
|
|
18
|
-
"--output-file <path>",
|
|
19
|
-
"Write the lint report to a file instead of stdout"
|
|
20
|
-
);
|
|
21
|
-
command.option(
|
|
22
|
-
"--max-warnings <number>",
|
|
23
|
-
"Fail if more than this number of warnings. -1 allows warnings. (default: -1)"
|
|
24
|
-
);
|
|
25
|
-
command.description("Lint a package");
|
|
26
|
-
command.action(lazy.lazy(() => import('./commands/package/lint.cjs.js'), "default"));
|
|
27
|
-
}
|
|
28
|
-
var index = factory.createCliPlugin({
|
|
29
|
-
pluginId: "lint",
|
|
30
|
-
init: async (reg) => {
|
|
31
|
-
reg.addCommand({
|
|
32
|
-
path: ["package", "lint"],
|
|
33
|
-
description: "Lint a package",
|
|
34
|
-
execute: async ({ args }) => {
|
|
35
|
-
const command = new commander.Command();
|
|
36
|
-
registerPackageLintCommand(command);
|
|
37
|
-
await command.parseAsync(args, { from: "user" });
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
reg.addCommand({
|
|
41
|
-
path: ["repo", "lint"],
|
|
42
|
-
description: "Lint a repository",
|
|
43
|
-
execute: async ({ args }) => {
|
|
44
|
-
const command = new commander.Command();
|
|
45
|
-
registerPackageLintCommand(command.command("package").command("lint"));
|
|
46
|
-
command.option("--fix", "Attempt to automatically fix violations");
|
|
47
|
-
command.option(
|
|
48
|
-
"--format <format>",
|
|
49
|
-
"Lint report output format",
|
|
50
|
-
"eslint-formatter-friendly"
|
|
51
|
-
);
|
|
52
|
-
command.option(
|
|
53
|
-
"--output-file <path>",
|
|
54
|
-
"Write the lint report to a file instead of stdout"
|
|
55
|
-
);
|
|
56
|
-
command.option(
|
|
57
|
-
"--successCache",
|
|
58
|
-
"Enable success caching, which skips running tests for unchanged packages that were successful in the previous run"
|
|
59
|
-
);
|
|
60
|
-
command.option(
|
|
61
|
-
"--successCacheDir <path>",
|
|
62
|
-
"Set the success cache location, (default: node_modules/.cache/backstage-cli)"
|
|
63
|
-
);
|
|
64
|
-
command.option(
|
|
65
|
-
"--since <ref>",
|
|
66
|
-
"Only lint packages that changed since the specified ref"
|
|
67
|
-
);
|
|
68
|
-
command.option(
|
|
69
|
-
"--max-warnings <number>",
|
|
70
|
-
"Fail if more than this number of warnings. -1 allows warnings. (default: -1)"
|
|
71
|
-
);
|
|
72
|
-
command.description("Lint a repository");
|
|
73
|
-
command.action(lazy.lazy(() => import('./commands/repo/lint.cjs.js'), "command"));
|
|
74
|
-
await command.parseAsync(args, { from: "user" });
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
exports.default = index;
|
|
81
|
-
exports.registerPackageLintCommand = registerPackageLintCommand;
|
|
82
|
-
//# sourceMappingURL=index.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
|