@astryxdesign/cli 0.7.2-canary.081ccea → 0.7.2-canary.085e145
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/README.md +104 -84
- package/api/build/_adapter.d.mts +8 -0
- package/api/build/_adapter.mjs +12 -1
- package/api/build/build.doc.mjs +4 -0
- package/api/build/kit/kit.mjs +3 -11
- package/api/component/_adapter.mjs +3 -11
- package/api/component/component.doc.mjs +6 -1
- package/api/discover/_adapter.d.mts +13 -0
- package/api/discover/_adapter.mjs +39 -17
- package/api/discover/discover.doc.mjs +3 -2
- package/api/discover/discover.mjs +22 -8
- package/api/discover/discover.type.d.mts +5 -3
- package/api/discover/discover.type.mjs +5 -3
- package/api/docs/_adapter.mjs +3 -2
- package/api/docs/docs.doc.mjs +2 -1
- package/api/docs/docs.mjs +2 -1
- package/api/docs/docs.test.mjs +5 -2
- package/api/docs/reference-blocks.test.mjs +1 -3
- package/api/doctor/_adapter.d.mts +108 -0
- package/api/doctor/_adapter.mjs +223 -4
- package/api/doctor/doctor.d.mts +199 -0
- package/api/doctor/doctor.doc.mjs +3 -2
- package/api/doctor/doctor.mjs +503 -31
- package/api/doctor/doctor.test.mjs +137 -14
- package/api/doctor/release-checks.test.mjs +156 -0
- package/api/doctor/theme-checks.mjs +16 -3
- package/api/doctor/theme-checks.test.mjs +87 -7
- package/api/error.d.mts +10 -0
- package/api/error.mjs +25 -0
- package/api/hook/_adapter.mjs +3 -11
- package/api/hook/hook.doc.mjs +4 -0
- package/api/hook/list/list.d.mts +1 -1
- package/api/init/_adapter.d.mts +22 -0
- package/api/init/_adapter.mjs +59 -0
- package/api/init/init.d.mts +7 -5
- package/api/init/init.doc.mjs +28 -7
- package/api/init/init.mjs +28 -4
- package/api/init/init.type.d.mts +48 -3
- package/api/init/init.type.mjs +37 -3
- package/api/init/run/run.d.mts +1 -1
- package/api/init/run/run.mjs +15 -4
- package/api/init/user/user.d.mts +14 -0
- package/api/init/user/user.mjs +87 -0
- package/api/init/user/user.test.mjs +232 -0
- package/api/integration/authoring-checks.mjs +2 -2
- package/api/integration/integrationCheck.doc.mjs +1 -1
- package/api/integration/pack-check.mjs +10 -9
- package/api/integration/pack-check.test.mjs +9 -15
- package/api/integration/validate-integration.d.mts +8 -0
- package/api/integration/validate-integration.mjs +27 -6
- package/api/integration/validate-integration.type.d.mts +8 -0
- package/api/integration/validate-integration.type.mjs +3 -1
- package/api/integration/validate-unread-theme-folders.test.mjs +3 -2
- package/api/integration/validateIntegration.doc.mjs +1 -1
- package/api/search/_adapter.d.mts +11 -0
- package/api/search/_adapter.mjs +25 -0
- package/api/search/search.d.mts +1 -1
- package/api/search/search.doc.mjs +8 -3
- package/api/search/search.mjs +38 -14
- package/api/search/search.test.mjs +4 -1
- package/api/search/search.type.d.mts +14 -1
- package/api/search/search.type.mjs +6 -1
- package/api/swizzle/_adapter.mjs +2 -2
- package/api/swizzle/copy/copy.mjs +1 -1
- package/api/template/template-integration.test.mjs +1 -1
- package/api/theme/_adapter.d.mts +16 -0
- package/api/theme/_adapter.mjs +32 -5
- package/api/theme/build/build.d.mts +2 -1
- package/api/theme/build/build.mjs +70 -14
- package/api/theme/build/build.packed-old-core.test.mjs +20 -3
- package/api/theme/build/font-warning.mjs +5 -3
- package/api/theme/build/font-warning.test.mjs +2 -1
- package/api/theme/remove/remove.test.mjs +2 -2
- package/api/theme/targets/targets.mjs +3 -10
- package/api/theme/themeTargets.doc.mjs +4 -0
- package/api/theme/use/use.test.mjs +1 -1
- package/api/upgrade/_adapter.mjs +1 -1
- package/api/upgrade/run/run.mjs +5 -1
- package/api/upgrade/upgrade.doc.mjs +2 -1
- package/api/upgrade/upgrade.mjs +5 -1
- package/assets/docs/getting-started.doc.mjs +23 -3
- package/assets/docs/tree/add-a-component.doc.mjs +11 -1
- package/assets/docs/tree/add-a-theme.doc.mjs +12 -2
- package/assets/docs/tree/add-a-topic.doc.mjs +43 -1
- package/assets/docs/tree/agent-guidance.doc.mjs +18 -4
- package/assets/docs/tree/building-blocks.doc.mjs +4 -0
- package/assets/docs/tree/check-the-props.doc.mjs +1 -1
- package/assets/docs/tree/check-your-docs.doc.mjs +5 -5
- package/assets/docs/tree/checks.doc.mjs +9 -9
- package/assets/docs/tree/ci-and-containers.doc.mjs +88 -0
- package/assets/docs/tree/cli-command.doc.mjs +142 -0
- package/assets/docs/tree/cli.doc.mjs +6 -0
- package/assets/docs/tree/codemods.doc.mjs +13 -3
- package/assets/docs/tree/commands.doc.mjs +7 -1
- package/assets/docs/tree/component-imports.doc.mjs +11 -1
- package/assets/docs/tree/components.doc.mjs +6 -0
- package/assets/docs/tree/computer-agent-guide.doc.mjs +160 -0
- package/assets/docs/tree/computer-integrations.doc.mjs +93 -0
- package/assets/docs/tree/configuration.doc.mjs +7 -3
- package/assets/docs/tree/debug-and-gap-reports.doc.mjs +11 -1
- package/assets/docs/tree/define-the-theme.doc.mjs +1 -1
- package/assets/docs/tree/describe-the-component.doc.mjs +1 -1
- package/assets/docs/tree/docs.doc.mjs +6 -0
- package/assets/docs/tree/extend-or-replace.doc.mjs +13 -3
- package/assets/docs/tree/generate-a-palette.doc.mjs +2 -2
- package/assets/docs/tree/global-integrations.doc.mjs +124 -0
- package/assets/docs/tree/global.doc.mjs +131 -0
- package/assets/docs/tree/grade-template-with-agent.doc.mjs +4 -4
- package/assets/docs/tree/install-once.doc.mjs +105 -0
- package/assets/docs/tree/integrations.doc.mjs +5 -1
- package/assets/docs/tree/layout.doc.mjs +1 -1
- package/assets/docs/tree/links.doc.mjs +1 -1
- package/assets/docs/tree/monorepos.doc.mjs +84 -0
- package/assets/docs/tree/problems.doc.mjs +205 -0
- package/assets/docs/tree/project-global-or-both.doc.mjs +131 -0
- package/assets/docs/tree/publishing.doc.mjs +2 -2
- package/assets/docs/tree/quick-start.doc.mjs +15 -5
- package/assets/docs/tree/reference.doc.mjs +192 -0
- package/assets/docs/tree/replace-a-core-component.doc.mjs +11 -1
- package/assets/docs/tree/replace-a-core-template.doc.mjs +4 -4
- package/assets/docs/tree/scaffold.doc.mjs +1 -1
- package/assets/docs/tree/sections-and-placement.doc.mjs +3 -3
- package/assets/docs/tree/see-it-in-an-app.doc.mjs +13 -3
- package/assets/docs/tree/short-and-findable.doc.mjs +3 -3
- package/assets/docs/tree/single-component.doc.mjs +3 -3
- package/assets/docs/tree/start-a-template.doc.mjs +15 -5
- package/assets/docs/tree/template-doc-overview.doc.mjs +1 -1
- package/assets/docs/tree/templates.doc.mjs +6 -0
- package/assets/docs/tree/test-in-an-app.doc.mjs +4 -4
- package/assets/docs/tree/test-template-in-app.doc.mjs +4 -4
- package/assets/docs/tree/themes.doc.mjs +4 -0
- package/assets/docs/tree/troubleshooting.doc.mjs +15 -7
- package/assets/docs/tree/uninstall.doc.mjs +109 -0
- package/assets/docs/tree/updates.doc.mjs +92 -0
- package/assets/docs/tree/upgrading.doc.mjs +2 -2
- package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +11 -1
- package/assets/docs/tree/verify-packed-template.doc.mjs +2 -2
- package/assets/docs/tree/versioning.doc.mjs +3 -3
- package/assets/docs/tree/who-answers.doc.mjs +119 -0
- package/assets/docs/tree/write-the-template-file.doc.mjs +3 -3
- package/assets/docs/working-with-ai.doc.mjs +23 -9
- package/authoring/debug/parse.d.mts +5 -5
- package/authoring/discover/discover.doc.mjs +6 -0
- package/authoring/doctypes/_schema.d.mts +8 -3
- package/authoring/doctypes/_schema.mjs +1 -0
- package/authoring/doctypes/command/command.doc.mjs +6 -0
- package/authoring/doctypes/command/type.ts +14 -0
- package/authoring/doctypes/reference/reference.doc.mjs +1 -1
- package/authoring/index.d.ts +1 -0
- package/authoring/integration/integration.doc.mjs +18 -2
- package/authoring/integration/parse.test.mjs +11 -0
- package/authoring/integration/schema.d.mts +14 -3
- package/authoring/integration/schema.mjs +33 -2
- package/authoring/integration/type.ts +8 -0
- package/clients/cli/bin/astryx.mjs +20 -3
- package/clients/cli/cli-command.test.mjs +166 -0
- package/clients/cli/commands/blog.doc.mjs +1 -0
- package/clients/cli/commands/build-theme.batch-report.test.mjs +14 -2
- package/clients/cli/commands/build-theme.font-warning.test.mjs +3 -3
- package/clients/cli/commands/build-theme.mjs +25 -12
- package/clients/cli/commands/build.doc.mjs +1 -0
- package/clients/cli/commands/build.exit-codes-doc.test.mjs +4 -0
- package/clients/cli/commands/component.doc.mjs +1 -0
- package/clients/cli/commands/discover.broken-integration.test.mjs +7 -6
- package/clients/cli/commands/discover.doc.mjs +8 -0
- package/clients/cli/commands/discover.no-source.test.mjs +1 -0
- package/clients/cli/commands/docs.doc.mjs +1 -0
- package/clients/cli/commands/docs.mjs +49 -19
- package/clients/cli/commands/docs.test.mjs +2 -2
- package/clients/cli/commands/doctor-integration-components.doc.mjs +1 -0
- package/clients/cli/commands/doctor-integration-docs.doc.mjs +1 -0
- package/clients/cli/commands/doctor-integration-templates.doc.mjs +1 -0
- package/clients/cli/commands/doctor-integration-validate.doc.mjs +10 -1
- package/clients/cli/commands/doctor-integration.test.mjs +4 -3
- package/clients/cli/commands/doctor.doc.mjs +12 -2
- package/clients/cli/commands/doctor.mjs +12 -3
- package/clients/cli/commands/doctor.test.mjs +10 -4
- package/clients/cli/commands/gap-report.doc.mjs +1 -0
- package/clients/cli/commands/hook.doc.mjs +1 -0
- package/clients/cli/commands/init.behavior.test.mjs +5 -0
- package/clients/cli/commands/init.doc.mjs +29 -3
- package/clients/cli/commands/integration-add.doc.mjs +7 -0
- package/clients/cli/commands/integration-authoring.test.mjs +3 -3
- package/clients/cli/commands/integration-check.doc.mjs +10 -2
- package/clients/cli/commands/integration-check.test.mjs +31 -1
- package/clients/cli/commands/integration-pack.doc.mjs +8 -1
- package/clients/cli/commands/integration-verify.doc.mjs +8 -1
- package/clients/cli/commands/integration.mjs +3 -2
- package/clients/cli/commands/json-contract.test.mjs +6 -1
- package/clients/cli/commands/manifest.doc.mjs +1 -0
- package/clients/cli/commands/outside-project.test.mjs +774 -0
- package/clients/cli/commands/search.doc.mjs +1 -0
- package/clients/cli/commands/search.mjs +16 -11
- package/clients/cli/commands/search.test.mjs +429 -296
- package/clients/cli/commands/setup-nudge.test.mjs +26 -4
- package/clients/cli/commands/swizzle.doc.mjs +7 -0
- package/clients/cli/commands/swizzle.routing.test.mjs +1 -1
- package/clients/cli/commands/template.doc.mjs +1 -0
- package/clients/cli/commands/theme-add-lifecycle.test.mjs +3 -3
- package/clients/cli/commands/theme-add.doc.mjs +8 -1
- package/clients/cli/commands/theme-build.doc.mjs +1 -0
- package/clients/cli/commands/theme-eject.doc.mjs +1 -0
- package/clients/cli/commands/theme-list.behavior.test.mjs +6 -0
- package/clients/cli/commands/theme-list.doc.mjs +1 -0
- package/clients/cli/commands/theme-palette-generate.doc.mjs +1 -0
- package/clients/cli/commands/theme-remove.doc.mjs +7 -0
- package/clients/cli/commands/theme-targets.doc.mjs +1 -0
- package/clients/cli/commands/theme-template.doc.mjs +1 -0
- package/clients/cli/commands/theme-use.doc.mjs +7 -0
- package/clients/cli/commands/upgrade.config-ordering.test.mjs +2 -1
- package/clients/cli/commands/upgrade.doc.mjs +8 -1
- package/clients/cli/commands/upgrade.file-protection.test.mjs +3 -2
- package/clients/cli/commands/upgrade.hook-output.test.mjs +2 -1
- package/clients/cli/index.mjs +84 -13
- package/clients/cli/lib/cli-error.mjs +4 -1
- package/clients/cli/lib/component-format.test.mjs +1 -1
- package/clients/cli/lib/define-command.mjs +2 -2
- package/clients/cli/lib/json-shim.mjs +3 -1
- package/clients/cli/lib/manifest.d.ts +9 -0
- package/clients/cli/lib/manifest.mjs +17 -1
- package/clients/cli/lib/manifest.test.mjs +25 -0
- package/foundation/agent-docs/agent-doc-state.d.mts +21 -6
- package/foundation/agent-docs/agent-doc-state.mjs +29 -7
- package/foundation/agent-docs/agent-docs.d.mts +2 -2
- package/foundation/agent-docs/agent-docs.mjs +3 -3
- package/foundation/agent-docs/computer-agent-text.d.mts +133 -0
- package/foundation/agent-docs/computer-agent-text.mjs +623 -0
- package/foundation/agent-docs/computer-agent-text.test.mjs +602 -0
- package/foundation/config/project.d.mts +35 -3
- package/foundation/config/project.mjs +145 -8
- package/foundation/config/project.test.mjs +66 -0
- package/foundation/config/theme-state.mjs +5 -4
- package/foundation/discovery/cli-self-docs.mjs +20 -3
- package/foundation/discovery/cli-self-docs.test.mjs +3 -2
- package/foundation/discovery/component-replacement.mjs +2 -1
- package/foundation/discovery/runner-allowlist.d.mts +40 -0
- package/foundation/discovery/runner-allowlist.mjs +53 -0
- package/foundation/discovery/template-needs.mjs +5 -2
- package/foundation/discovery/theme-imports.mjs +8 -4
- package/foundation/discovery/theme-imports.test.mjs +1 -1
- package/foundation/doc-compiler/doc-loads.test.mjs +20 -0
- package/foundation/doc-compiler/inputs.mjs +4 -1
- package/foundation/doc-compiler/read.d.mts +1 -1
- package/foundation/doc-compiler/tree.test.mjs +1 -1
- package/foundation/env/cli-command.d.mts +83 -0
- package/foundation/env/cli-command.mjs +152 -0
- package/foundation/env/cli-command.test.mjs +129 -0
- package/foundation/env/node-version.test.mjs +15 -3
- package/foundation/env/package-manager.d.mts +61 -9
- package/foundation/env/package-manager.global.test.mjs +66 -0
- package/foundation/env/package-manager.mjs +137 -13
- package/foundation/env/package-manager.test.mjs +148 -9
- package/foundation/env/project-scope.d.mts +9 -0
- package/foundation/env/project-scope.mjs +33 -0
- package/foundation/env/search-path.d.mts +42 -0
- package/foundation/env/search-path.mjs +205 -0
- package/foundation/env/search-path.test.mjs +122 -0
- package/foundation/env/user-dirs.d.mts +39 -0
- package/foundation/env/user-dirs.mjs +93 -0
- package/foundation/env/user-dirs.test.mjs +72 -0
- package/foundation/env/user-settings.d.mts +46 -0
- package/foundation/env/user-settings.mjs +106 -0
- package/foundation/env/user-settings.test.mjs +64 -0
- package/foundation/fs/file-protection.mjs +15 -1
- package/foundation/fs/module-loader.stdout.test.mjs +3 -2
- package/foundation/fs/path-compare.d.mts +33 -0
- package/foundation/fs/path-compare.mjs +73 -0
- package/foundation/fs/paths.d.mts +57 -1
- package/foundation/fs/paths.mjs +131 -3
- package/foundation/fs/paths.test.mjs +10 -1
- package/foundation/integrations/computer-integrations.d.mts +78 -0
- package/foundation/integrations/computer-integrations.mjs +316 -0
- package/foundation/integrations/computer-integrations.test.mjs +292 -0
- package/foundation/integrations/integration-warnings.mjs +3 -2
- package/foundation/integrations/integration-warnings.test.mjs +8 -9
- package/foundation/integrations/integrations.d.mts +25 -1
- package/foundation/integrations/integrations.mjs +46 -3
- package/foundation/integrations/validate-contributions.d.mts +2 -0
- package/foundation/integrations/validate-contributions.mjs +11 -0
- package/foundation/release/agent-text-worker.d.mts +4 -0
- package/foundation/release/agent-text-worker.mjs +52 -0
- package/foundation/release/cache.d.mts +310 -0
- package/foundation/release/cache.mjs +1216 -0
- package/foundation/release/cache.test.mjs +920 -0
- package/foundation/release/choose.d.mts +207 -0
- package/foundation/release/choose.mjs +677 -0
- package/foundation/release/choose.test.mjs +427 -0
- package/foundation/release/core-worker.d.mts +4 -0
- package/foundation/release/core-worker.mjs +38 -0
- package/foundation/release/global-state.d.mts +259 -0
- package/foundation/release/global-state.mjs +472 -0
- package/foundation/release/global-state.test.mjs +381 -0
- package/foundation/release/handoff.d.mts +60 -0
- package/foundation/release/handoff.e2e.test.mjs +278 -0
- package/foundation/release/handoff.mjs +357 -0
- package/foundation/release/lock-lease.d.mts +23 -0
- package/foundation/release/lock-lease.mjs +80 -0
- package/foundation/release/notices.d.mts +253 -0
- package/foundation/release/notices.mjs +596 -0
- package/foundation/release/notices.test.mjs +565 -0
- package/foundation/release/npm-guard.d.mts +4 -0
- package/foundation/release/npm-guard.mjs +126 -0
- package/foundation/release/project.d.mts +141 -0
- package/foundation/release/project.mjs +466 -0
- package/foundation/release/project.test.mjs +288 -0
- package/foundation/release/refresh-worker.d.mts +4 -0
- package/foundation/release/refresh-worker.mjs +27 -0
- package/foundation/release/run-context.d.mts +47 -0
- package/foundation/release/run-context.mjs +149 -0
- package/foundation/release/update-notice-env.d.mts +28 -0
- package/foundation/release/update-notice-env.mjs +39 -0
- package/foundation/response/base.d.ts +26 -3
- package/foundation/response/error-codes.d.mts +3 -1
- package/foundation/response/error-codes.doc.mjs +12 -0
- package/foundation/response/error-codes.mjs +17 -0
- package/foundation/response/error-codes.test.mjs +2 -0
- package/foundation/response/json-contract.test.mjs +7 -2
- package/foundation/response/json.mjs +4 -1
- package/foundation/response/response-types.doc.mjs +8 -3
- package/foundation/response/response-types.doc.test.mjs +46 -0
- package/foundation/response/response.doc.mjs +3 -3
- package/foundation/xle/browser-imports.test.mjs +74 -0
- package/package.json +9 -9
- package/scripts/postinstall.mjs +21 -2
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file Computer-level integrations (spec AST-081 FR12): the integration
|
|
5
|
+
* packages installed in the same install root as the running copy of the CLI,
|
|
6
|
+
* such as a package manager's global folder beside a global copy, or the
|
|
7
|
+
* package set a door installs together.
|
|
8
|
+
*
|
|
9
|
+
* - The install root is the folder whose `node_modules` holds the running
|
|
10
|
+
* CLI package (above pnpm's `.pnpm` store). pnpm 11 and later give each
|
|
11
|
+
* global package a folder of its own, and every one of them counts. A
|
|
12
|
+
* package runner's temporary install and the per-user release cache are not
|
|
13
|
+
* install roots: they hold what one run asked for.
|
|
14
|
+
* - When the root has a package.json, its declared dependencies are read, as
|
|
15
|
+
* autolink reads a project's; otherwise (npm's global folder) every package
|
|
16
|
+
* directly in its `node_modules`, scoped ones included. Either way, only a
|
|
17
|
+
* package with exactly one root `astryx.integration.*` manifest counts, and
|
|
18
|
+
* the CLI and Core packages never do.
|
|
19
|
+
* - Outside a project they load as a project's integrations do (Project.load).
|
|
20
|
+
* One whose declared `@astryxdesign/core` or `@astryxdesign/cli` peer range
|
|
21
|
+
* excludes the answering release is skipped, and doctor says why.
|
|
22
|
+
* - Inside a project none load; discover lists the ones the project does not
|
|
23
|
+
* install as available, and doctor names them.
|
|
24
|
+
*
|
|
25
|
+
* Listing reads package.json files only; nothing is imported until a load.
|
|
26
|
+
*
|
|
27
|
+
* @input the running CLI package's folder
|
|
28
|
+
* @output the computer-level integration candidates, and their loaded records
|
|
29
|
+
* @position foundation/integrations — read by config/project, discover, and
|
|
30
|
+
* doctor.
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
import * as fs from 'node:fs';
|
|
34
|
+
import * as path from 'node:path';
|
|
35
|
+
import {findManifestPaths, loadIntegrations} from './integrations.mjs';
|
|
36
|
+
import {
|
|
37
|
+
readDeclaredDependencies,
|
|
38
|
+
resolveInstalledPackageDir,
|
|
39
|
+
} from './autolink.mjs';
|
|
40
|
+
import {installPlaceOf} from '../release/choose.mjs';
|
|
41
|
+
import {isInReleaseCache} from '../release/cache.mjs';
|
|
42
|
+
import {satisfiesRange} from '../env/semver.mjs';
|
|
43
|
+
|
|
44
|
+
/** Packages that are the CLI itself, never an integration of it. */
|
|
45
|
+
const NOT_INTEGRATIONS = new Set(['@astryxdesign/cli', '@astryxdesign/core']);
|
|
46
|
+
|
|
47
|
+
/** Peers whose ranges must admit the answering release. */
|
|
48
|
+
const RELEASE_PEERS = ['@astryxdesign/core', '@astryxdesign/cli'];
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* @typedef {object} ComputerIntegrationCandidate
|
|
52
|
+
* @property {string} name the package name
|
|
53
|
+
* @property {string | undefined} version
|
|
54
|
+
* @property {string | undefined} description
|
|
55
|
+
* @property {string} packageDir
|
|
56
|
+
* @property {string} hostDir the folder whose node_modules holds it
|
|
57
|
+
* @property {string | null} incompatible why its peer ranges exclude the
|
|
58
|
+
* answering release, or null
|
|
59
|
+
*/
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* @param {string} p
|
|
63
|
+
* @returns {string}
|
|
64
|
+
*/
|
|
65
|
+
function real(p) {
|
|
66
|
+
try {
|
|
67
|
+
return fs.realpathSync(p);
|
|
68
|
+
} catch {
|
|
69
|
+
return path.resolve(p);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* @param {string} dir
|
|
75
|
+
* @returns {Record<string, any> | null}
|
|
76
|
+
*/
|
|
77
|
+
function readPackage(dir) {
|
|
78
|
+
try {
|
|
79
|
+
const pkg = JSON.parse(
|
|
80
|
+
fs.readFileSync(path.join(dir, 'package.json'), 'utf8'),
|
|
81
|
+
);
|
|
82
|
+
return pkg && typeof pkg === 'object' ? pkg : null;
|
|
83
|
+
} catch {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* The install root of the CLI package at `cliRoot`, or null when it has none
|
|
90
|
+
* that counts: it is not installed in a `node_modules` folder, or it lives in
|
|
91
|
+
* a package runner's temporary install or the per-user release cache.
|
|
92
|
+
* @param {string} cliRoot
|
|
93
|
+
* @param {{cacheDir?: string}} [options]
|
|
94
|
+
* @returns {string | null}
|
|
95
|
+
*/
|
|
96
|
+
export function computerInstallRoot(cliRoot, options = {}) {
|
|
97
|
+
const root = real(cliRoot);
|
|
98
|
+
const place = installPlaceOf(root);
|
|
99
|
+
if (place.runner || !place.owner) return null;
|
|
100
|
+
if (isInReleaseCache(root, options.cacheDir)) return null;
|
|
101
|
+
return place.owner;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Every install root that holds packages installed with the CLI at
|
|
106
|
+
* `cliRoot`. Usually one: its install root. pnpm 11 and later install each
|
|
107
|
+
* global package in a folder of its own, `<pnpm home>/global/v<N>/<id>`, with
|
|
108
|
+
* its files in `<pnpm home>/store/v<N>/links` or inside that folder, so every
|
|
109
|
+
* such global folder counts, provided one of them installs this CLI.
|
|
110
|
+
* @param {string} cliRoot
|
|
111
|
+
* @param {{cacheDir?: string}} [options]
|
|
112
|
+
* @returns {string[]}
|
|
113
|
+
*/
|
|
114
|
+
export function computerInstallRoots(cliRoot, options = {}) {
|
|
115
|
+
const fromPnpm = pnpmGlobalFolders(real(cliRoot));
|
|
116
|
+
if (fromPnpm.length > 0) return fromPnpm;
|
|
117
|
+
const root = computerInstallRoot(cliRoot, options);
|
|
118
|
+
return root ? [root] : [];
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* pnpm's global folders for a CLI installed globally by pnpm 11 or later, or
|
|
123
|
+
* none. Its files are either in pnpm's store (`<home>/store/v<N>/links/...`,
|
|
124
|
+
* with the global virtual store) or inside its own global folder
|
|
125
|
+
* (`<home>/global/v<N>/<id>/node_modules/...`, without it).
|
|
126
|
+
* @param {string} cli the CLI package's real path
|
|
127
|
+
* @returns {string[]}
|
|
128
|
+
*/
|
|
129
|
+
function pnpmGlobalFolders(cli) {
|
|
130
|
+
const parts = cli.split(/[\\/]/);
|
|
131
|
+
/** @type {string | null} */
|
|
132
|
+
let globalDir = null;
|
|
133
|
+
const storeAt = parts.lastIndexOf('store');
|
|
134
|
+
if (
|
|
135
|
+
storeAt > 0 &&
|
|
136
|
+
/^v\d+$/.test(parts[storeAt + 1] ?? '') &&
|
|
137
|
+
parts[storeAt + 2] === 'links'
|
|
138
|
+
) {
|
|
139
|
+
const home = parts.slice(0, storeAt).join(path.sep) || path.sep;
|
|
140
|
+
globalDir = path.join(home, 'global', parts[storeAt + 1]);
|
|
141
|
+
} else {
|
|
142
|
+
const at = parts.findIndex(
|
|
143
|
+
(part, k) =>
|
|
144
|
+
part === 'global' &&
|
|
145
|
+
/^v\d+$/.test(parts[k + 1] ?? '') &&
|
|
146
|
+
parts[k + 3] === 'node_modules',
|
|
147
|
+
);
|
|
148
|
+
if (at > 0) globalDir = parts.slice(0, at + 2).join(path.sep) || path.sep;
|
|
149
|
+
}
|
|
150
|
+
if (globalDir == null) return [];
|
|
151
|
+
/** @type {string[]} */
|
|
152
|
+
let names;
|
|
153
|
+
try {
|
|
154
|
+
names = fs.readdirSync(globalDir).sort();
|
|
155
|
+
} catch {
|
|
156
|
+
return [];
|
|
157
|
+
}
|
|
158
|
+
const folders = names
|
|
159
|
+
.map(name => path.join(globalDir, name))
|
|
160
|
+
.filter(dir => fs.existsSync(path.join(dir, 'package.json')));
|
|
161
|
+
const installsThisCli = folders.some(
|
|
162
|
+
dir => real(path.join(dir, 'node_modules', '@astryxdesign', 'cli')) === cli,
|
|
163
|
+
);
|
|
164
|
+
return installsThisCli ? folders : [];
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Every package name directly in `<root>/node_modules`, scoped ones included.
|
|
169
|
+
* @param {string} root
|
|
170
|
+
* @returns {string[]}
|
|
171
|
+
*/
|
|
172
|
+
function installedNames(root) {
|
|
173
|
+
const modules = path.join(root, 'node_modules');
|
|
174
|
+
/** @type {string[]} */
|
|
175
|
+
const names = [];
|
|
176
|
+
/** @type {fs.Dirent[]} */
|
|
177
|
+
let entries;
|
|
178
|
+
try {
|
|
179
|
+
entries = fs.readdirSync(modules, {withFileTypes: true});
|
|
180
|
+
} catch {
|
|
181
|
+
return names;
|
|
182
|
+
}
|
|
183
|
+
for (const entry of entries) {
|
|
184
|
+
if (entry.name.startsWith('.')) continue;
|
|
185
|
+
if (entry.name.startsWith('@')) {
|
|
186
|
+
try {
|
|
187
|
+
for (const scoped of fs.readdirSync(path.join(modules, entry.name))) {
|
|
188
|
+
if (!scoped.startsWith('.')) names.push(`${entry.name}/${scoped}`);
|
|
189
|
+
}
|
|
190
|
+
} catch {
|
|
191
|
+
// An unreadable scope folder holds nothing to read.
|
|
192
|
+
}
|
|
193
|
+
} else {
|
|
194
|
+
names.push(entry.name);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
return names.sort();
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Why `pkg`'s peer ranges exclude `release`, or null when they admit it.
|
|
202
|
+
* @param {Record<string, any>} pkg
|
|
203
|
+
* @param {string} release the answering release's version
|
|
204
|
+
* @returns {string | null}
|
|
205
|
+
*/
|
|
206
|
+
export function peerProblem(pkg, release) {
|
|
207
|
+
const peers = pkg.peerDependencies;
|
|
208
|
+
if (!peers || typeof peers !== 'object') return null;
|
|
209
|
+
for (const peer of RELEASE_PEERS) {
|
|
210
|
+
const range = peers[peer];
|
|
211
|
+
if (typeof range !== 'string') continue;
|
|
212
|
+
let admits;
|
|
213
|
+
try {
|
|
214
|
+
admits = satisfiesRange(release, range);
|
|
215
|
+
} catch {
|
|
216
|
+
// A range this CLI cannot read never keeps the integration out.
|
|
217
|
+
admits = true;
|
|
218
|
+
}
|
|
219
|
+
if (!admits) {
|
|
220
|
+
return `it needs ${peer} ${range}, and this computer's CLI is ${release}`;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
return null;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* The computer-level integrations installed beside the CLI at `cliRoot`, in
|
|
228
|
+
* name order (declaration order when the root declares them). Reads
|
|
229
|
+
* package.json files only.
|
|
230
|
+
* @param {{cliRoot: string, release: string, cacheDir?: string}} options
|
|
231
|
+
* @returns {ComputerIntegrationCandidate[]}
|
|
232
|
+
*/
|
|
233
|
+
export function scanComputerIntegrations({cliRoot, release, cacheDir}) {
|
|
234
|
+
const self = real(cliRoot);
|
|
235
|
+
/** @type {ComputerIntegrationCandidate[]} */
|
|
236
|
+
const found = [];
|
|
237
|
+
const seen = new Set();
|
|
238
|
+
for (const root of computerInstallRoots(cliRoot, {cacheDir})) {
|
|
239
|
+
scanRoot(root, {self, release, found, seen});
|
|
240
|
+
}
|
|
241
|
+
return found;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Add the integrations installed in one install root.
|
|
246
|
+
* @param {string} root
|
|
247
|
+
* @param {{self: string, release: string, found: ComputerIntegrationCandidate[], seen: Set<string>}} into
|
|
248
|
+
*/
|
|
249
|
+
function scanRoot(root, {self, release, found, seen}) {
|
|
250
|
+
const declared = readPackage(root)
|
|
251
|
+
? readDeclaredDependencies(root).map(d => d.name)
|
|
252
|
+
: installedNames(root);
|
|
253
|
+
for (const name of declared) {
|
|
254
|
+
if (NOT_INTEGRATIONS.has(name)) continue;
|
|
255
|
+
const resolved = resolveInstalledPackageDir(name, root);
|
|
256
|
+
if (!resolved) continue;
|
|
257
|
+
const identity = real(resolved.packageDir);
|
|
258
|
+
if (identity === self || seen.has(identity)) continue;
|
|
259
|
+
if (findManifestPaths(resolved.packageDir).length !== 1) continue;
|
|
260
|
+
const pkg = readPackage(resolved.packageDir);
|
|
261
|
+
if (!pkg || typeof pkg.name !== 'string') continue;
|
|
262
|
+
if (NOT_INTEGRATIONS.has(pkg.name)) continue;
|
|
263
|
+
seen.add(identity);
|
|
264
|
+
found.push({
|
|
265
|
+
name: pkg.name,
|
|
266
|
+
version: typeof pkg.version === 'string' ? pkg.version : undefined,
|
|
267
|
+
description:
|
|
268
|
+
typeof pkg.description === 'string' ? pkg.description : undefined,
|
|
269
|
+
packageDir: resolved.packageDir,
|
|
270
|
+
hostDir: resolved.hostDir,
|
|
271
|
+
incompatible: peerProblem(pkg, release),
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Load the compatible computer-level integrations as provider candidates,
|
|
278
|
+
* each in isolation, under the autolinked policy (a broken one is recorded
|
|
279
|
+
* and contributes nothing; the same package reached twice loads once). Each
|
|
280
|
+
* loaded record is marked `__computer`. An incompatible one is not loaded.
|
|
281
|
+
* @param {ComputerIntegrationCandidate[]} candidates
|
|
282
|
+
* @param {{fresh?: boolean, exclude?: Iterable<string>}} [options] `exclude`
|
|
283
|
+
* names packages the folder already loads, which keep their own copy
|
|
284
|
+
* @returns {Promise<import('./provider-resolution.mjs').ProviderCandidate[]>}
|
|
285
|
+
*/
|
|
286
|
+
export async function loadComputerIntegrations(candidates, options = {}) {
|
|
287
|
+
const {fresh = false, exclude = []} = options;
|
|
288
|
+
const taken = new Set(exclude);
|
|
289
|
+
/** @type {import('./provider-resolution.mjs').ProviderCandidate[]} */
|
|
290
|
+
const loaded = [];
|
|
291
|
+
for (const candidate of candidates) {
|
|
292
|
+
if (candidate.incompatible || taken.has(candidate.name)) continue;
|
|
293
|
+
try {
|
|
294
|
+
const [integration] = await loadIntegrations([candidate.name], {
|
|
295
|
+
cwd: candidate.hostDir,
|
|
296
|
+
fresh,
|
|
297
|
+
});
|
|
298
|
+
loaded.push({
|
|
299
|
+
source: 'autolinked',
|
|
300
|
+
spec: candidate.name,
|
|
301
|
+
packageDir: candidate.packageDir,
|
|
302
|
+
...(integration == null
|
|
303
|
+
? {}
|
|
304
|
+
: {integration: {...integration, __computer: true}}),
|
|
305
|
+
});
|
|
306
|
+
} catch (error) {
|
|
307
|
+
loaded.push({
|
|
308
|
+
source: 'autolinked',
|
|
309
|
+
spec: candidate.name,
|
|
310
|
+
packageDir: candidate.packageDir,
|
|
311
|
+
error: error instanceof Error ? error.message : String(error),
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
return loaded;
|
|
316
|
+
}
|
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file Computer-level integrations (spec AST-081 FR12): which install root
|
|
5
|
+
* counts, which packages in it are integrations, and the peer-range check.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import {afterEach, describe, expect, it} from 'vitest';
|
|
9
|
+
import * as fs from 'node:fs';
|
|
10
|
+
import * as path from 'node:path';
|
|
11
|
+
import {
|
|
12
|
+
computerInstallRoot,
|
|
13
|
+
computerInstallRoots,
|
|
14
|
+
loadComputerIntegrations,
|
|
15
|
+
peerProblem,
|
|
16
|
+
scanComputerIntegrations,
|
|
17
|
+
} from './computer-integrations.mjs';
|
|
18
|
+
import {
|
|
19
|
+
cleanupFixtures,
|
|
20
|
+
tempDir,
|
|
21
|
+
writeJson,
|
|
22
|
+
} from '../../test-utils/release-fixtures.mjs';
|
|
23
|
+
|
|
24
|
+
afterEach(cleanupFixtures);
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* A package at `dir`, with a manifest when `manifest` is set.
|
|
28
|
+
* @param {string} dir
|
|
29
|
+
* @param {Record<string, unknown>} pkg
|
|
30
|
+
* @param {string | null} [manifest]
|
|
31
|
+
*/
|
|
32
|
+
function pkgAt(dir, pkg, manifest = 'export default {};\n') {
|
|
33
|
+
writeJson(path.join(dir, 'package.json'), pkg);
|
|
34
|
+
if (manifest != null) {
|
|
35
|
+
fs.writeFileSync(path.join(dir, 'astryx.integration.mjs'), manifest);
|
|
36
|
+
}
|
|
37
|
+
return dir;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** An npm-style global folder (no package.json) holding the CLI and others. */
|
|
41
|
+
function npmGlobal() {
|
|
42
|
+
const root = path.join(tempDir('prefix'), 'lib');
|
|
43
|
+
const modules = path.join(root, 'node_modules');
|
|
44
|
+
const cli = pkgAt(
|
|
45
|
+
path.join(modules, '@astryxdesign', 'cli'),
|
|
46
|
+
{name: '@astryxdesign/cli', version: '0.8.0'},
|
|
47
|
+
null,
|
|
48
|
+
);
|
|
49
|
+
pkgAt(path.join(modules, '@astryxdesign', 'core'), {
|
|
50
|
+
name: '@astryxdesign/core',
|
|
51
|
+
version: '0.8.0',
|
|
52
|
+
});
|
|
53
|
+
pkgAt(path.join(modules, '@acme', 'widgets'), {
|
|
54
|
+
name: '@acme/widgets',
|
|
55
|
+
version: '1.2.0',
|
|
56
|
+
description: 'Acme widgets',
|
|
57
|
+
});
|
|
58
|
+
pkgAt(path.join(modules, 'plain-tool'), {name: 'plain-tool'}, null);
|
|
59
|
+
pkgAt(path.join(modules, 'zeta-kit'), {
|
|
60
|
+
name: 'zeta-kit',
|
|
61
|
+
version: '2.0.0',
|
|
62
|
+
peerDependencies: {'@astryxdesign/core': '>=9.0.0'},
|
|
63
|
+
});
|
|
64
|
+
return {root, cli};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
describe('computerInstallRoot', () => {
|
|
68
|
+
it('is the folder whose node_modules holds the CLI; none for a runner cache or a folder outside node_modules', () => {
|
|
69
|
+
const {root, cli} = npmGlobal();
|
|
70
|
+
expect(computerInstallRoot(cli)).toBe(fs.realpathSync(root));
|
|
71
|
+
const runner = pkgAt(
|
|
72
|
+
path.join(
|
|
73
|
+
tempDir('npx'),
|
|
74
|
+
'_npx',
|
|
75
|
+
'ab12',
|
|
76
|
+
'node_modules',
|
|
77
|
+
'@astryxdesign',
|
|
78
|
+
'cli',
|
|
79
|
+
),
|
|
80
|
+
{name: '@astryxdesign/cli', version: '0.8.0'},
|
|
81
|
+
null,
|
|
82
|
+
);
|
|
83
|
+
expect(computerInstallRoot(runner)).toBeNull();
|
|
84
|
+
expect(computerInstallRoot(tempDir('checkout'))).toBeNull();
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it('is none for a release in the per-user release cache', () => {
|
|
88
|
+
const cacheDir = tempDir('cache');
|
|
89
|
+
const cli = pkgAt(
|
|
90
|
+
path.join(
|
|
91
|
+
cacheDir,
|
|
92
|
+
'releases',
|
|
93
|
+
'0.8.0',
|
|
94
|
+
'node_modules',
|
|
95
|
+
'@astryxdesign',
|
|
96
|
+
'cli',
|
|
97
|
+
),
|
|
98
|
+
{name: '@astryxdesign/cli', version: '0.8.0'},
|
|
99
|
+
null,
|
|
100
|
+
);
|
|
101
|
+
expect(computerInstallRoot(cli, {cacheDir})).toBeNull();
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
describe('computerInstallRoots', () => {
|
|
106
|
+
it("is pnpm's shared global folder before pnpm 11", () => {
|
|
107
|
+
const g5 = path.join(tempDir('pnpm'), 'global', '5');
|
|
108
|
+
const cli = pkgAt(
|
|
109
|
+
path.join(
|
|
110
|
+
g5,
|
|
111
|
+
'.pnpm',
|
|
112
|
+
'@astryxdesign+cli@0.8.0',
|
|
113
|
+
'node_modules',
|
|
114
|
+
'@astryxdesign',
|
|
115
|
+
'cli',
|
|
116
|
+
),
|
|
117
|
+
{name: '@astryxdesign/cli', version: '0.8.0'},
|
|
118
|
+
null,
|
|
119
|
+
);
|
|
120
|
+
expect(computerInstallRoots(cli)).toEqual([fs.realpathSync(g5)]);
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
it('is every pnpm global folder since pnpm 11, when one of them installs this CLI', () => {
|
|
124
|
+
const home = tempDir('pnpm-home');
|
|
125
|
+
const cli = pkgAt(
|
|
126
|
+
path.join(
|
|
127
|
+
home,
|
|
128
|
+
'store',
|
|
129
|
+
'v11',
|
|
130
|
+
'links',
|
|
131
|
+
'@astryxdesign',
|
|
132
|
+
'cli',
|
|
133
|
+
'0.8.0',
|
|
134
|
+
'h',
|
|
135
|
+
'node_modules',
|
|
136
|
+
'@astryxdesign',
|
|
137
|
+
'cli',
|
|
138
|
+
),
|
|
139
|
+
{name: '@astryxdesign/cli', version: '0.8.0'},
|
|
140
|
+
null,
|
|
141
|
+
);
|
|
142
|
+
const a = path.join(home, 'global', 'v11', 'a');
|
|
143
|
+
const b = path.join(home, 'global', 'v11', 'b');
|
|
144
|
+
writeJson(path.join(b, 'package.json'), {
|
|
145
|
+
dependencies: {'@acme/widgets': '1.0.0'},
|
|
146
|
+
});
|
|
147
|
+
// No global folder installs this CLI yet: only its own install root.
|
|
148
|
+
expect(computerInstallRoots(cli)).toHaveLength(1);
|
|
149
|
+
writeJson(path.join(a, 'package.json'), {
|
|
150
|
+
dependencies: {'@astryxdesign/cli': '0.8.0'},
|
|
151
|
+
});
|
|
152
|
+
fs.mkdirSync(path.join(a, 'node_modules', '@astryxdesign'), {
|
|
153
|
+
recursive: true,
|
|
154
|
+
});
|
|
155
|
+
fs.symlinkSync(cli, path.join(a, 'node_modules', '@astryxdesign', 'cli'));
|
|
156
|
+
expect(computerInstallRoots(cli)).toEqual([a, b]);
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
it("is every pnpm global folder when the CLI's files sit inside its own global folder (pnpm 12)", () => {
|
|
160
|
+
const globalDir = path.join(tempDir('pnpm12'), 'global', 'v11');
|
|
161
|
+
const a = path.join(globalDir, 'a');
|
|
162
|
+
const b = path.join(globalDir, 'b');
|
|
163
|
+
writeJson(path.join(a, 'package.json'), {
|
|
164
|
+
dependencies: {'@astryxdesign/cli': '0.8.0'},
|
|
165
|
+
});
|
|
166
|
+
const cli = pkgAt(
|
|
167
|
+
path.join(
|
|
168
|
+
a,
|
|
169
|
+
'node_modules',
|
|
170
|
+
'.pnpm',
|
|
171
|
+
'@astryxdesign+cli@0.8.0',
|
|
172
|
+
'node_modules',
|
|
173
|
+
'@astryxdesign',
|
|
174
|
+
'cli',
|
|
175
|
+
),
|
|
176
|
+
{name: '@astryxdesign/cli', version: '0.8.0'},
|
|
177
|
+
null,
|
|
178
|
+
);
|
|
179
|
+
fs.mkdirSync(path.join(a, 'node_modules', '@astryxdesign'), {
|
|
180
|
+
recursive: true,
|
|
181
|
+
});
|
|
182
|
+
fs.symlinkSync(cli, path.join(a, 'node_modules', '@astryxdesign', 'cli'));
|
|
183
|
+
writeJson(path.join(b, 'package.json'), {
|
|
184
|
+
dependencies: {'@acme/widgets': '1.0.0'},
|
|
185
|
+
});
|
|
186
|
+
pkgAt(path.join(b, 'node_modules', '@acme', 'widgets'), {
|
|
187
|
+
name: '@acme/widgets',
|
|
188
|
+
version: '1.0.0',
|
|
189
|
+
});
|
|
190
|
+
expect(computerInstallRoots(cli)).toEqual([
|
|
191
|
+
fs.realpathSync(a),
|
|
192
|
+
fs.realpathSync(b),
|
|
193
|
+
]);
|
|
194
|
+
expect(
|
|
195
|
+
scanComputerIntegrations({cliRoot: cli, release: '0.8.0'}).map(
|
|
196
|
+
c => c.name,
|
|
197
|
+
),
|
|
198
|
+
).toEqual(['@acme/widgets']);
|
|
199
|
+
});
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
describe('scanComputerIntegrations', () => {
|
|
203
|
+
it('lists every package beside the CLI that ships a manifest, never the CLI or Core, and marks an incompatible one', () => {
|
|
204
|
+
const {cli} = npmGlobal();
|
|
205
|
+
const found = scanComputerIntegrations({cliRoot: cli, release: '0.8.0'});
|
|
206
|
+
expect(found.map(c => [c.name, c.version, c.incompatible])).toEqual([
|
|
207
|
+
['@acme/widgets', '1.2.0', null],
|
|
208
|
+
[
|
|
209
|
+
'zeta-kit',
|
|
210
|
+
'2.0.0',
|
|
211
|
+
"it needs @astryxdesign/core >=9.0.0, and this computer's CLI is 0.8.0",
|
|
212
|
+
],
|
|
213
|
+
]);
|
|
214
|
+
expect(found[0].description).toBe('Acme widgets');
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
it("reads a door's package set from the root's declared dependencies", () => {
|
|
218
|
+
const root = tempDir('runtime');
|
|
219
|
+
writeJson(path.join(root, 'package.json'), {
|
|
220
|
+
name: 'runtime',
|
|
221
|
+
private: true,
|
|
222
|
+
dependencies: {
|
|
223
|
+
'@astryxdesign/cli': '0.8.0',
|
|
224
|
+
'@astryxdesign/core': '0.8.0',
|
|
225
|
+
'@acme/meta-kit': '3.0.0',
|
|
226
|
+
},
|
|
227
|
+
});
|
|
228
|
+
const modules = path.join(root, 'node_modules');
|
|
229
|
+
const cli = pkgAt(
|
|
230
|
+
path.join(modules, '@astryxdesign', 'cli'),
|
|
231
|
+
{name: '@astryxdesign/cli', version: '0.8.0'},
|
|
232
|
+
null,
|
|
233
|
+
);
|
|
234
|
+
pkgAt(path.join(modules, '@acme', 'meta-kit'), {
|
|
235
|
+
name: '@acme/meta-kit',
|
|
236
|
+
version: '3.0.0',
|
|
237
|
+
});
|
|
238
|
+
// Installed but not declared: not part of the set.
|
|
239
|
+
pkgAt(path.join(modules, 'stray-kit'), {name: 'stray-kit'});
|
|
240
|
+
expect(
|
|
241
|
+
scanComputerIntegrations({cliRoot: cli, release: '0.8.0'}).map(
|
|
242
|
+
c => c.name,
|
|
243
|
+
),
|
|
244
|
+
).toEqual(['@acme/meta-kit']);
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
it('lists nothing for a copy with no install root', () => {
|
|
248
|
+
expect(
|
|
249
|
+
scanComputerIntegrations({
|
|
250
|
+
cliRoot: tempDir('checkout'),
|
|
251
|
+
release: '0.8.0',
|
|
252
|
+
}),
|
|
253
|
+
).toEqual([]);
|
|
254
|
+
});
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
describe('peerProblem', () => {
|
|
258
|
+
it('checks the Core and CLI peer ranges against the answering release', () => {
|
|
259
|
+
expect(peerProblem({}, '0.8.0')).toBeNull();
|
|
260
|
+
expect(
|
|
261
|
+
peerProblem(
|
|
262
|
+
{peerDependencies: {'@astryxdesign/core': '^0.8.0'}},
|
|
263
|
+
'0.8.2',
|
|
264
|
+
),
|
|
265
|
+
).toBeNull();
|
|
266
|
+
expect(
|
|
267
|
+
peerProblem(
|
|
268
|
+
{peerDependencies: {'@astryxdesign/cli': '>=0.9.0'}},
|
|
269
|
+
'0.8.2',
|
|
270
|
+
),
|
|
271
|
+
).toBe(
|
|
272
|
+
"it needs @astryxdesign/cli >=0.9.0, and this computer's CLI is 0.8.2",
|
|
273
|
+
);
|
|
274
|
+
expect(
|
|
275
|
+
peerProblem({peerDependencies: {react: '>=99'}}, '0.8.2'),
|
|
276
|
+
).toBeNull();
|
|
277
|
+
});
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
describe('loadComputerIntegrations', () => {
|
|
281
|
+
it("loads the compatible ones, marked as the computer's, and leaves out excluded and incompatible ones", async () => {
|
|
282
|
+
const {cli} = npmGlobal();
|
|
283
|
+
const found = scanComputerIntegrations({cliRoot: cli, release: '0.8.0'});
|
|
284
|
+
const loaded = await loadComputerIntegrations(found);
|
|
285
|
+
expect(loaded.map(c => [c.spec, c.integration?.__computer])).toEqual([
|
|
286
|
+
['@acme/widgets', true],
|
|
287
|
+
]);
|
|
288
|
+
expect(
|
|
289
|
+
await loadComputerIntegrations(found, {exclude: ['@acme/widgets']}),
|
|
290
|
+
).toEqual([]);
|
|
291
|
+
});
|
|
292
|
+
});
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
*/
|
|
22
22
|
|
|
23
23
|
import {validateLoadedIntegration} from './validate-contributions.mjs';
|
|
24
|
+
import {formatCliCommand} from '../env/package-manager.mjs';
|
|
24
25
|
|
|
25
26
|
/**
|
|
26
27
|
* For each configured (already-loaded) integration, compute its issues using
|
|
@@ -81,8 +82,8 @@ export async function warnOnIntegrationIssues(source, {json = false} = {}) {
|
|
|
81
82
|
|
|
82
83
|
for (const [pkg, count] of issueCounts) {
|
|
83
84
|
const command = fromProject
|
|
84
|
-
? '
|
|
85
|
-
: `
|
|
85
|
+
? formatCliCommand('doctor')
|
|
86
|
+
: formatCliCommand(`doctor integration validate ${pkg}`);
|
|
86
87
|
console.error(
|
|
87
88
|
`Warning: ${pkg} has ${count} integration issue(s). Run: ${command}`,
|
|
88
89
|
);
|
|
@@ -61,9 +61,8 @@ describe('warnOnIntegrationIssues', () => {
|
|
|
61
61
|
await warnOnIntegrationIssues([integration], {json: false});
|
|
62
62
|
|
|
63
63
|
expect(errLines).toHaveLength(1);
|
|
64
|
-
expect(errLines[0]).
|
|
65
|
-
|
|
66
|
-
'Run: astryx doctor integration validate @acme/widgets',
|
|
64
|
+
expect(errLines[0]).toMatch(
|
|
65
|
+
/^Warning: @acme\/widgets has 1 integration issue\(s\)\. Run: .+ doctor integration validate @acme\/widgets$/,
|
|
67
66
|
);
|
|
68
67
|
});
|
|
69
68
|
|
|
@@ -81,9 +80,10 @@ describe('warnOnIntegrationIssues', () => {
|
|
|
81
80
|
|
|
82
81
|
await warnOnIntegrationIssues(project, {json: false});
|
|
83
82
|
|
|
84
|
-
expect(errLines).
|
|
85
|
-
|
|
86
|
-
|
|
83
|
+
expect(errLines).toHaveLength(1);
|
|
84
|
+
expect(errLines[0]).toMatch(
|
|
85
|
+
/^Warning: @acme\/later has 1 integration issue\(s\)\. Run: .+ doctor$/,
|
|
86
|
+
);
|
|
87
87
|
});
|
|
88
88
|
|
|
89
89
|
it('emits nothing in --json mode (keeps stdout/JSON clean)', async () => {
|
|
@@ -103,9 +103,8 @@ describe('warnOnIntegrationIssues', () => {
|
|
|
103
103
|
await warnOnIntegrationIssues([integration], {json: false});
|
|
104
104
|
|
|
105
105
|
expect(errLines).toHaveLength(1);
|
|
106
|
-
expect(errLines[0]).
|
|
107
|
-
|
|
108
|
-
'Run: astryx doctor integration validate @acme/stale',
|
|
106
|
+
expect(errLines[0]).toMatch(
|
|
107
|
+
/^Warning: @acme\/stale has 1 integration issue\(s\)\. Run: .+ doctor integration validate @acme\/stale$/,
|
|
109
108
|
);
|
|
110
109
|
});
|
|
111
110
|
|