@astryxdesign/cli 0.7.2-canary.081ccea → 0.7.2-canary.0d5d64e
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
|
@@ -19,9 +19,12 @@
|
|
|
19
19
|
|
|
20
20
|
import {createHash} from 'node:crypto';
|
|
21
21
|
import * as fs from 'node:fs';
|
|
22
|
-
import * as os from 'node:os';
|
|
23
22
|
import * as path from 'node:path';
|
|
24
|
-
import {
|
|
23
|
+
import {
|
|
24
|
+
Project,
|
|
25
|
+
availableComputerIntegrations,
|
|
26
|
+
} from '../../foundation/config/project.mjs';
|
|
27
|
+
import {isOutsideProject} from '../../foundation/env/project-scope.mjs';
|
|
25
28
|
import {
|
|
26
29
|
scanAllPackages,
|
|
27
30
|
findComponentInPackages,
|
|
@@ -31,6 +34,7 @@ import {collectIdentities} from '../../foundation/integrations/contribution-inve
|
|
|
31
34
|
import {detectPackageManager} from '../../foundation/env/package-manager.mjs';
|
|
32
35
|
import {isValidSemver, semverCompare} from '../../foundation/env/semver.mjs';
|
|
33
36
|
import {assertWithin} from '../../foundation/fs/path-safety.mjs';
|
|
37
|
+
import {userCacheDir} from '../../foundation/env/user-dirs.mjs';
|
|
34
38
|
import {CLI_ROOT, findInstalledPackage} from '../../foundation/fs/paths.mjs';
|
|
35
39
|
import {parseDiscoverCatalog} from '../../authoring/discover/parse.mjs';
|
|
36
40
|
import {AstryxError} from '../error.mjs';
|
|
@@ -245,6 +249,38 @@ export function hasSources(project) {
|
|
|
245
249
|
);
|
|
246
250
|
}
|
|
247
251
|
|
|
252
|
+
/** The source name of a package installed for the computer. */
|
|
253
|
+
const COMPUTER_SOURCE = 'installed for this computer';
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* The integrations installed for the computer that a project could add, as
|
|
257
|
+
* available entries with the project's install command (spec AST-081 FR12).
|
|
258
|
+
* Empty outside a project, where they load instead.
|
|
259
|
+
* @param {Project | undefined} project
|
|
260
|
+
* @param {Array<{name: string}>} installed
|
|
261
|
+
* @param {Set<string>} declared
|
|
262
|
+
* @param {(name: string, version?: string) => string} add
|
|
263
|
+
* @returns {Promise<import('./discover.type.mjs').DiscoverAvailableEntry[]>}
|
|
264
|
+
*/
|
|
265
|
+
export async function computerAvailableEntries(
|
|
266
|
+
project,
|
|
267
|
+
installed,
|
|
268
|
+
declared,
|
|
269
|
+
add,
|
|
270
|
+
) {
|
|
271
|
+
const cwd = project?.cwd ?? process.cwd();
|
|
272
|
+
if (isOutsideProject(cwd)) return [];
|
|
273
|
+
const have = new Set([...installed.map(pkg => pkg.name), ...declared]);
|
|
274
|
+
return (await availableComputerIntegrations(cwd, have)).map(c => ({
|
|
275
|
+
name: c.name,
|
|
276
|
+
components: [],
|
|
277
|
+
...(c.version ? {version: c.version} : {}),
|
|
278
|
+
...(c.description ? {description: c.description} : {}),
|
|
279
|
+
source: COMPUTER_SOURCE,
|
|
280
|
+
install: add(c.name),
|
|
281
|
+
}));
|
|
282
|
+
}
|
|
283
|
+
|
|
248
284
|
/**
|
|
249
285
|
* Package names the project's package.json declares in any dependency field.
|
|
250
286
|
* @param {Project | undefined} project
|
|
@@ -438,21 +474,7 @@ export function addCommand(project, {official = []} = {}) {
|
|
|
438
474
|
* @returns {string}
|
|
439
475
|
*/
|
|
440
476
|
export function defaultCacheDir() {
|
|
441
|
-
|
|
442
|
-
if (process.platform === 'win32') {
|
|
443
|
-
return path.join(
|
|
444
|
-
process.env.LOCALAPPDATA || path.join(home, 'AppData', 'Local'),
|
|
445
|
-
'astryx',
|
|
446
|
-
'Cache',
|
|
447
|
-
);
|
|
448
|
-
}
|
|
449
|
-
if (process.platform === 'darwin') {
|
|
450
|
-
return path.join(home, 'Library', 'Caches', 'astryx');
|
|
451
|
-
}
|
|
452
|
-
return path.join(
|
|
453
|
-
process.env.XDG_CACHE_HOME || path.join(home, '.cache'),
|
|
454
|
-
'astryx',
|
|
455
|
-
);
|
|
477
|
+
return userCacheDir();
|
|
456
478
|
}
|
|
457
479
|
|
|
458
480
|
/**
|
|
@@ -21,7 +21,8 @@ export const doc = {
|
|
|
21
21
|
'project and its integrations list, with what each one adds per kind. An @scope/name query shows one package with every ' +
|
|
22
22
|
'version its source knows; @scope/name@version shows one version; @scope/name/Component returns an installed ' +
|
|
23
23
|
"component's validated doc, and any other item path returns that item. A free-text term searches every item and " +
|
|
24
|
-
'package. Discover only reads: it prints the command that adds a package and never runs it.'
|
|
24
|
+
'package. Discover only reads: it prints the command that adds a package and never runs it.' +
|
|
25
|
+
" In global mode: with `cwd` outside a project, integrations installed next to this CLI package globally are listed as installed; inside a project, only the project's own are, and the compatible global ones are listed in `meta.available` with source `installed for this computer` and an `install` command. See {@link namespace:global} and {@link generic:computer-integrations}.",
|
|
25
26
|
importPath: '@astryxdesign/cli/api',
|
|
26
27
|
signature:
|
|
27
28
|
'discover(query?: string, options?: DiscoverOptions): Promise<DiscoverListResponse | DiscoverDetailResponse | DiscoverDetailDocResponse | DiscoverItemResponse | DiscoverSearchResponse>',
|
|
@@ -90,7 +91,7 @@ export const doc = {
|
|
|
90
91
|
{
|
|
91
92
|
type: 'discover.list',
|
|
92
93
|
description:
|
|
93
|
-
'What the project has: the integrations it loads and the official packages it declares (name, category, components, version, and a list per other kind they add), official packages first. meta.available lists what the project could add, official packages first, each with the command that adds it, and meta.sources reports each source, the official list last. When it lists no integration it carries meta.configured.',
|
|
94
|
+
'What the project has: the integrations it loads and the official packages it declares (name, category, components, version, and a list per other kind they add), official packages first. meta.available lists what the project could add, official packages first, each with the command that adds it; inside a project, an integration installed for the computer that the project does not install is listed there too, with source `installed for this computer` and the install command for the project in `install`. meta.sources reports each source, the official list last. When it lists no integration it carries meta.configured.',
|
|
94
95
|
},
|
|
95
96
|
{
|
|
96
97
|
type: 'discover.detail',
|
|
@@ -27,6 +27,7 @@ export {OFFICIAL_SOURCE_NAME} from './_adapter.mjs';
|
|
|
27
27
|
import {
|
|
28
28
|
addCommand,
|
|
29
29
|
callSources,
|
|
30
|
+
computerAvailableEntries,
|
|
30
31
|
declaredDependencies,
|
|
31
32
|
describeInstalled,
|
|
32
33
|
discoverPackages,
|
|
@@ -216,18 +217,31 @@ export async function discover(query, options = {}) {
|
|
|
216
217
|
if (!query || (integrations.length === 0 && !hasSources(project))) {
|
|
217
218
|
const catalog = await catalogFor();
|
|
218
219
|
const packages = installedFor(catalog);
|
|
220
|
+
// Inside a project, the integrations installed for the computer are
|
|
221
|
+
// available, never loaded (spec AST-081 FR12).
|
|
222
|
+
const computer = await computerAvailableEntries(
|
|
223
|
+
project,
|
|
224
|
+
packages,
|
|
225
|
+
declared,
|
|
226
|
+
add,
|
|
227
|
+
);
|
|
228
|
+
const fromSources = officialFirst(
|
|
229
|
+
availableEntries(catalog, packages, declared, {
|
|
230
|
+
officialDeclared: declarations.any,
|
|
231
|
+
install: installFor,
|
|
232
|
+
}),
|
|
233
|
+
official.packages,
|
|
234
|
+
entry => entry.name,
|
|
235
|
+
);
|
|
236
|
+
const named = new Set(fromSources.map(entry => entry.name));
|
|
219
237
|
return list(withLatest(packages, catalog), {
|
|
220
238
|
configured,
|
|
221
239
|
type,
|
|
222
240
|
only,
|
|
223
|
-
available:
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
}),
|
|
228
|
-
official.packages,
|
|
229
|
-
entry => entry.name,
|
|
230
|
-
),
|
|
241
|
+
available: [
|
|
242
|
+
...fromSources,
|
|
243
|
+
...computer.filter(entry => !named.has(entry.name)),
|
|
244
|
+
],
|
|
231
245
|
sources: catalog.sources,
|
|
232
246
|
});
|
|
233
247
|
}
|
|
@@ -94,12 +94,14 @@ export type DiscoverAvailableEntry = {
|
|
|
94
94
|
aliases?: string[] | undefined;
|
|
95
95
|
/**
|
|
96
96
|
* The discover source that lists it; `Astryx` for
|
|
97
|
-
* the official list
|
|
97
|
+
* the official list; `installed for this computer` for an integration
|
|
98
|
+
* installed beside the CLI that the project does not install (spec AST-081
|
|
99
|
+
* FR12).
|
|
98
100
|
*/
|
|
99
101
|
source: string;
|
|
100
102
|
/**
|
|
101
|
-
* The package-manager command that adds it
|
|
102
|
-
* discover prints it and never runs it.
|
|
103
|
+
* The package-manager command that adds it to
|
|
104
|
+
* this project; discover prints it and never runs it.
|
|
103
105
|
*/
|
|
104
106
|
install?: string | undefined;
|
|
105
107
|
};
|
|
@@ -71,9 +71,11 @@
|
|
|
71
71
|
* @property {string} [description]
|
|
72
72
|
* @property {string[]} [aliases] The integration's other package names.
|
|
73
73
|
* @property {string} source The discover source that lists it; `Astryx` for
|
|
74
|
-
* the official list
|
|
75
|
-
*
|
|
76
|
-
*
|
|
74
|
+
* the official list; `installed for this computer` for an integration
|
|
75
|
+
* installed beside the CLI that the project does not install (spec AST-081
|
|
76
|
+
* FR12).
|
|
77
|
+
* @property {string} [install] The package-manager command that adds it to
|
|
78
|
+
* this project; discover prints it and never runs it.
|
|
77
79
|
*/
|
|
78
80
|
|
|
79
81
|
/**
|
package/api/docs/_adapter.mjs
CHANGED
|
@@ -70,6 +70,7 @@ import {
|
|
|
70
70
|
import {findCoreDir} from '../../foundation/fs/paths.mjs';
|
|
71
71
|
import {AstryxError} from '../error.mjs';
|
|
72
72
|
import {ERROR_CODES} from '../../foundation/response/error-codes.mjs';
|
|
73
|
+
import {formatCliCommand} from '../../foundation/env/package-manager.mjs';
|
|
73
74
|
|
|
74
75
|
export {OVERLAY_LANGUAGES, overlayLanguages};
|
|
75
76
|
|
|
@@ -1596,7 +1597,7 @@ export async function unknownTopicError(topic, catalog) {
|
|
|
1596
1597
|
export function notLoaded(catalog) {
|
|
1597
1598
|
const packages = [...new Set(catalog.issues.map(issue => issue.package))];
|
|
1598
1599
|
if (packages.length === 0) return '';
|
|
1599
|
-
return `. The docs of ${packages.join(', ')} did not load; run
|
|
1600
|
+
return `. The docs of ${packages.join(', ')} did not load; run \`${formatCliCommand('doctor integration docs')}\` in that package to see why.`;
|
|
1600
1601
|
}
|
|
1601
1602
|
|
|
1602
1603
|
/**
|
|
@@ -1614,7 +1615,7 @@ export async function resolveTopicDocs(topic, options = {}) {
|
|
|
1614
1615
|
if (found.kind !== 'topic') {
|
|
1615
1616
|
throw found.kind === 'node'
|
|
1616
1617
|
? new AstryxError(
|
|
1617
|
-
`"${found.node.route}" is a ${found.node.kind === 'namespace' ? 'namespace' : `${found.node.kind} doc`} in the docs tree, not a topic. Read it with
|
|
1618
|
+
`"${found.node.route}" is a ${found.node.kind === 'namespace' ? 'namespace' : `${found.node.kind} doc`} in the docs tree, not a topic. Read it with \`${formatCliCommand(`docs ${found.node.route}`)}\`.`,
|
|
1618
1619
|
undefined,
|
|
1619
1620
|
ERROR_CODES.ERR_UNKNOWN_TOPIC,
|
|
1620
1621
|
)
|
package/api/docs/docs.doc.mjs
CHANGED
|
@@ -34,7 +34,8 @@ export const doc = {
|
|
|
34
34
|
'for a typed doc, `related` to the docs it names (its command or function, ' +
|
|
35
35
|
'and its related docs); `previous` and `next` ' +
|
|
36
36
|
'to the section or node before and after it. ' +
|
|
37
|
-
'Overlay options select localized or dense variants.'
|
|
37
|
+
'Overlay options select localized or dense variants.' +
|
|
38
|
+
" In global mode: with `cwd` outside a project, doc topics from integrations installed next to this CLI package globally are listed too; inside a project, only the project's own integrations count. See {@link namespace:global} and {@link generic:computer-integrations}.",
|
|
38
39
|
importPath: '@astryxdesign/cli/api',
|
|
39
40
|
signature:
|
|
40
41
|
'docs(topic?: string, section?: string, options?: DocsOptions): Promise<DocsListResponse | DocsIndexResponse | DocsDetailResponse | DocsDetailSectionResponse | DocsNodeResponse>',
|
package/api/docs/docs.mjs
CHANGED
|
@@ -34,6 +34,7 @@ import {node as nodeLeaf, nodeView} from './node/node.mjs';
|
|
|
34
34
|
import {resolveDocsArgument} from './_adapter.mjs';
|
|
35
35
|
import {AstryxError} from '../error.mjs';
|
|
36
36
|
import {ERROR_CODES} from '../../foundation/response/error-codes.mjs';
|
|
37
|
+
import {formatCliCommand} from '../../foundation/env/package-manager.mjs';
|
|
37
38
|
|
|
38
39
|
export {list, index, detail, sectionLeaf as section, nodeLeaf as node};
|
|
39
40
|
|
|
@@ -108,7 +109,7 @@ export async function docs(topic, section, options = {}) {
|
|
|
108
109
|
return namespaceSection(found.tree, found.node, section, options);
|
|
109
110
|
}
|
|
110
111
|
throw new AstryxError(
|
|
111
|
-
`"${found.node.route}" has no sections. Read it whole:
|
|
112
|
+
`"${found.node.route}" has no sections. Read it whole: ${formatCliCommand(`docs ${found.node.route}`)}.`,
|
|
112
113
|
[{name: found.node.route, reason: found.node.summary}],
|
|
113
114
|
ERROR_CODES.ERR_UNKNOWN_SECTION,
|
|
114
115
|
);
|
package/api/docs/docs.test.mjs
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
import {describe, it, expect} from 'vitest';
|
|
12
12
|
import {docs} from './docs.mjs';
|
|
13
13
|
import {AstryxError} from '../error.mjs';
|
|
14
|
+
import {formatCliCommand} from '../../foundation/env/package-manager.mjs';
|
|
14
15
|
|
|
15
16
|
const SLOW = 30_000;
|
|
16
17
|
|
|
@@ -92,7 +93,7 @@ describe('docs() dispatcher routing', () => {
|
|
|
92
93
|
|
|
93
94
|
it("lists the docs tree's namespaces in meta, so every data entry reads as a topic", async () => {
|
|
94
95
|
const res = await docs();
|
|
95
|
-
expect(res.meta.namespaces.map(entry => entry.topic)).toEqual(['cli', 'internationalization', 'layout', 'migration', 'styling', 'styling-libraries', 'tokens', 'typography', 'unorganized']);
|
|
96
|
+
expect(res.meta.namespaces.map(entry => entry.topic)).toEqual(['cli', 'global', 'internationalization', 'layout', 'migration', 'styling', 'styling-libraries', 'tokens', 'typography', 'unorganized']);
|
|
96
97
|
for (const entry of res.data) {
|
|
97
98
|
expect((await docs(entry.topic)).type).toBe('docs.detail');
|
|
98
99
|
}
|
|
@@ -107,7 +108,9 @@ describe('docs() dispatcher routing', () => {
|
|
|
107
108
|
it('a section of a typed doc -> ERR_UNKNOWN_SECTION, suggesting the doc itself', async () => {
|
|
108
109
|
const err = await docs('cli/api/functions/search', 'x').catch(e => e);
|
|
109
110
|
expect(err.code).toBe('ERR_UNKNOWN_SECTION');
|
|
110
|
-
expect(err.message).toContain(
|
|
111
|
+
expect(err.message).toContain(
|
|
112
|
+
formatCliCommand('docs cli/api/functions/search'),
|
|
113
|
+
);
|
|
111
114
|
expect(err.suggestions.map(s => s.name)).toEqual(['cli/api/functions/search']);
|
|
112
115
|
}, SLOW);
|
|
113
116
|
|
|
@@ -276,9 +276,7 @@ describe('a reference block in a topic section', () => {
|
|
|
276
276
|
expect(status).toBe(0);
|
|
277
277
|
expect(stdout).toMatch(/^Field +\| Type +\| Required +\| Description/m);
|
|
278
278
|
expect(stdout).toMatch(/^components +\| string +\| no +\| /m);
|
|
279
|
-
expect(stdout).toContain(
|
|
280
|
-
'From Astryx Integration: `astryx docs authoring integration`',
|
|
281
|
-
);
|
|
279
|
+
expect(stdout).toContain(' docs authoring integration`');
|
|
282
280
|
},
|
|
283
281
|
SLOW,
|
|
284
282
|
);
|
|
@@ -43,8 +43,116 @@ export function findDoctorInstalledPackage(projectDir: string, packageName: stri
|
|
|
43
43
|
export function listDoctorThemePackages(cwd: string): string[];
|
|
44
44
|
/** @param {string} file */
|
|
45
45
|
export function readPackageJson(file: string): any;
|
|
46
|
+
/**
|
|
47
|
+
* The integrations installed for the computer, and, outside a project, which
|
|
48
|
+
* of them the folder loads (spec AST-081 FR12): those it uses, and the names
|
|
49
|
+
* of the integrations the folder loads itself, whose copies win.
|
|
50
|
+
* @param {string} cwd
|
|
51
|
+
* @returns {Promise<{computerIntegrations: import('../../foundation/integrations/computer-integrations.mjs').ComputerIntegrationCandidate[], loadedComputerIntegrations: string[], folderIntegrations: string[]}>}
|
|
52
|
+
*/
|
|
53
|
+
export function computerIntegrationsOutside(cwd: string): Promise<{
|
|
54
|
+
computerIntegrations: import("../../foundation/integrations/computer-integrations.mjs").ComputerIntegrationCandidate[];
|
|
55
|
+
loadedComputerIntegrations: string[];
|
|
56
|
+
folderIntegrations: string[];
|
|
57
|
+
}>;
|
|
58
|
+
/**
|
|
59
|
+
* Inside a project: the integrations installed for the computer it could add
|
|
60
|
+
* (spec AST-081 FR12), leaving out every package it loads or declares.
|
|
61
|
+
* @param {string} cwd
|
|
62
|
+
* @param {string[]} loadedNames the integrations the project loads
|
|
63
|
+
* @returns {Promise<import('../../foundation/integrations/computer-integrations.mjs').ComputerIntegrationCandidate[]>}
|
|
64
|
+
*/
|
|
65
|
+
export function computerIntegrationsToAdd(cwd: string, loadedNames: string[]): Promise<import("../../foundation/integrations/computer-integrations.mjs").ComputerIntegrationCandidate[]>;
|
|
66
|
+
/**
|
|
67
|
+
* The computer-level agent text's setting and its state on disk.
|
|
68
|
+
* @returns {{settings: import('../../foundation/env/user-settings.mjs').ComputerAgentTextSettings, entries: Array<{path: string, state: import('../../foundation/agent-docs/computer-agent-text.mjs').ComputerAgentTextState, link?: true}>}}
|
|
69
|
+
*/
|
|
70
|
+
export function computerAgentTextState(): {
|
|
71
|
+
settings: import("../../foundation/env/user-settings.mjs").ComputerAgentTextSettings;
|
|
72
|
+
entries: Array<{
|
|
73
|
+
path: string;
|
|
74
|
+
state: import("../../foundation/agent-docs/computer-agent-text.mjs").ComputerAgentTextState;
|
|
75
|
+
link?: true;
|
|
76
|
+
}>;
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* The release facts doctor reports, read here so the checks stay pure
|
|
80
|
+
* (spec AST-081 FR5, FR6, FR10; architecture:cli-surface INV21): who
|
|
81
|
+
* answered, the newest release the computer knows of, how far the global copy
|
|
82
|
+
* or the project is behind, and every `astryx` on the search path with the
|
|
83
|
+
* command that upgrades it.
|
|
84
|
+
* @param {string} cwd
|
|
85
|
+
* @param {{project: boolean}} options
|
|
86
|
+
* @returns {{answeredBy: {cli: string, core: string | null, copy: string}, latest: string | null, globalBehind: ReturnType<typeof globalBehind> | null, projectLag: ReturnType<typeof projectLag> | null, lastNoticeSkip: ReturnType<typeof lastNoticeSkip>, lastCheckFailure: ReturnType<typeof lastCheckFailure>, stateLock: ReturnType<typeof stateLockHolder>, searchPathCommands: Array<import('../../foundation/env/search-path.mjs').SearchPathCommand & {upgrade: string | null}>}}
|
|
87
|
+
*/
|
|
88
|
+
export function releaseFacts(cwd: string, { project }: {
|
|
89
|
+
project: boolean;
|
|
90
|
+
}): {
|
|
91
|
+
answeredBy: {
|
|
92
|
+
cli: string;
|
|
93
|
+
core: string | null;
|
|
94
|
+
copy: string;
|
|
95
|
+
};
|
|
96
|
+
latest: string | null;
|
|
97
|
+
globalBehind: ReturnType<typeof globalBehind> | null;
|
|
98
|
+
projectLag: ReturnType<typeof projectLag> | null;
|
|
99
|
+
lastNoticeSkip: ReturnType<typeof lastNoticeSkip>;
|
|
100
|
+
lastCheckFailure: ReturnType<typeof lastCheckFailure>;
|
|
101
|
+
stateLock: ReturnType<typeof stateLockHolder>;
|
|
102
|
+
searchPathCommands: Array<import("../../foundation/env/search-path.mjs").SearchPathCommand & {
|
|
103
|
+
upgrade: string | null;
|
|
104
|
+
}>;
|
|
105
|
+
};
|
|
106
|
+
/** Whether `cwd` is outside every project. */
|
|
107
|
+
export function outsideProject(cwd: string): boolean;
|
|
108
|
+
/**
|
|
109
|
+
* The commands that bring a project's own CLI and Core to one release, with
|
|
110
|
+
* the project's package manager: Core up to the CLI, then its codemods, when
|
|
111
|
+
* the CLI is newer; else the CLI to the Core's release.
|
|
112
|
+
* @param {string} cwd
|
|
113
|
+
* @param {string} cli
|
|
114
|
+
* @param {string} core
|
|
115
|
+
* @returns {string}
|
|
116
|
+
*/
|
|
117
|
+
export function alignCommand(cwd: string, cli: string, core: string): string;
|
|
118
|
+
/**
|
|
119
|
+
* The Core release the project at `cwd` names: installed, else locked, else
|
|
120
|
+
* declared; the version the daily hint and notice compare against (spec
|
|
121
|
+
* AST-081 FR2). Null outside a project or when it names none.
|
|
122
|
+
* @param {string} cwd
|
|
123
|
+
* @returns {string | null}
|
|
124
|
+
*/
|
|
125
|
+
export function projectCoreVersion(cwd: string): string | null;
|
|
126
|
+
/**
|
|
127
|
+
* Whether the project at `cwd` installs its own CLI (spec AST-081 FR2).
|
|
128
|
+
* @param {string} cwd
|
|
129
|
+
* @returns {boolean}
|
|
130
|
+
*/
|
|
131
|
+
export function projectHasOwnCli(cwd: string): boolean;
|
|
132
|
+
/**
|
|
133
|
+
* The command that adds the CLI at `version` with the project's package
|
|
134
|
+
* manager.
|
|
135
|
+
* @param {string} cwd
|
|
136
|
+
* @param {string} version
|
|
137
|
+
* @returns {string}
|
|
138
|
+
*/
|
|
139
|
+
export function addCliCommandFor(cwd: string, version: string): string;
|
|
140
|
+
/**
|
|
141
|
+
* The command that adds a package with the folder's package manager, read
|
|
142
|
+
* from its lockfiles and `packageManager` field.
|
|
143
|
+
* @param {string} cwd
|
|
144
|
+
* @returns {(name: string) => string}
|
|
145
|
+
*/
|
|
146
|
+
export function installCommandFor(cwd: string): (name: string) => string;
|
|
46
147
|
export { resolveRecordedTheme } from "../theme/theme.mjs";
|
|
47
148
|
export { collectUnloadedFonts } from "../theme/build/font-warning.mjs";
|
|
48
149
|
export const SOURCE_EXTENSIONS: Set<string>;
|
|
150
|
+
export { displayHomePath };
|
|
151
|
+
import { globalBehind } from '../../foundation/release/notices.mjs';
|
|
152
|
+
import { projectLag } from '../../foundation/release/notices.mjs';
|
|
153
|
+
import { lastNoticeSkip } from '../../foundation/release/notices.mjs';
|
|
154
|
+
import { lastCheckFailure } from '../../foundation/release/global-state.mjs';
|
|
155
|
+
import { stateLockHolder } from '../../foundation/release/global-state.mjs';
|
|
156
|
+
import { displayHomePath } from '../../foundation/agent-docs/computer-agent-text.mjs';
|
|
49
157
|
export { isLocalThemeOwner, planThemeAppWrite, readThemeState, resolveThemeModule } from "../../foundation/config/theme-state.mjs";
|
|
50
158
|
export { themeBuild, validateThemePrivateInputs } from "../theme/build/build.mjs";
|
package/api/doctor/_adapter.mjs
CHANGED
|
@@ -2,15 +2,52 @@
|
|
|
2
2
|
|
|
3
3
|
/** @file Environment adapter for app-theme doctor evidence. */
|
|
4
4
|
|
|
5
|
+
import {isOutsideProject} from '../../foundation/env/project-scope.mjs';
|
|
6
|
+
import {answeredBy} from '../../foundation/release/run-context.mjs';
|
|
7
|
+
import {
|
|
8
|
+
knownLatestRelease,
|
|
9
|
+
lastCheckFailure,
|
|
10
|
+
stateLockHolder,
|
|
11
|
+
} from '../../foundation/release/global-state.mjs';
|
|
12
|
+
import {
|
|
13
|
+
addCliCommand,
|
|
14
|
+
alignCliAndCore,
|
|
15
|
+
globalBehind,
|
|
16
|
+
globalUpgradeCommand,
|
|
17
|
+
lastNoticeSkip,
|
|
18
|
+
projectLag,
|
|
19
|
+
} from '../../foundation/release/notices.mjs';
|
|
20
|
+
import {
|
|
21
|
+
coreVersionOf,
|
|
22
|
+
isGlobalCopy,
|
|
23
|
+
projectRootOf,
|
|
24
|
+
} from '../../foundation/release/choose.mjs';
|
|
25
|
+
import {readReleaseFacts} from '../../foundation/release/project.mjs';
|
|
26
|
+
import {detectPackageManager} from '../../foundation/env/package-manager.mjs';
|
|
27
|
+
import {astryxCommandsOnSearchPath} from '../../foundation/env/search-path.mjs';
|
|
28
|
+
import {readDeclaredDependencies} from '../../foundation/integrations/autolink.mjs';
|
|
29
|
+
import {
|
|
30
|
+
displayHomePath,
|
|
31
|
+
inspectComputerAgentText,
|
|
32
|
+
} from '../../foundation/agent-docs/computer-agent-text.mjs';
|
|
33
|
+
import {computerAgentTextSettings} from '../../foundation/env/user-settings.mjs';
|
|
5
34
|
import * as fs from 'node:fs';
|
|
6
35
|
import * as path from 'node:path';
|
|
7
|
-
import {
|
|
36
|
+
import {
|
|
37
|
+
Project,
|
|
38
|
+
availableComputerIntegrations,
|
|
39
|
+
computerIntegrationCandidates,
|
|
40
|
+
} from '../../foundation/config/project.mjs';
|
|
8
41
|
import {
|
|
9
42
|
discoverUnmigratedThemeCopies,
|
|
10
43
|
themeImportPackage,
|
|
11
44
|
} from '../../foundation/discovery/theme-discovery.mjs';
|
|
12
45
|
import {resolveThemeImports} from '../../foundation/discovery/theme-imports.mjs';
|
|
13
|
-
import {
|
|
46
|
+
import {
|
|
47
|
+
CLI_ROOT,
|
|
48
|
+
findProjectCoreDir,
|
|
49
|
+
findInstalledPackage,
|
|
50
|
+
} from '../../foundation/fs/paths.mjs';
|
|
14
51
|
export {
|
|
15
52
|
isLocalThemeOwner,
|
|
16
53
|
planThemeAppWrite,
|
|
@@ -104,7 +141,7 @@ export function listProjectSourceFiles(root, generatedModule) {
|
|
|
104
141
|
|
|
105
142
|
/** @param {string} projectDir */
|
|
106
143
|
export async function discoverDoctorThemes(projectDir) {
|
|
107
|
-
const project = await Project.load(projectDir);
|
|
144
|
+
const project = await Project.load(projectDir, {core: 'project'});
|
|
108
145
|
return project.themes();
|
|
109
146
|
}
|
|
110
147
|
|
|
@@ -124,7 +161,7 @@ export function discoverDoctorUnmigratedCopies(projectDir) {
|
|
|
124
161
|
|
|
125
162
|
/** @param {string} projectDir */
|
|
126
163
|
export function findDoctorCoreDir(projectDir) {
|
|
127
|
-
return
|
|
164
|
+
return findProjectCoreDir(projectDir);
|
|
128
165
|
}
|
|
129
166
|
|
|
130
167
|
/** @param {string} projectDir @param {string} packageName */
|
|
@@ -188,3 +225,185 @@ export function readPackageJson(file) {
|
|
|
188
225
|
return null;
|
|
189
226
|
}
|
|
190
227
|
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* The integrations installed for the computer, and, outside a project, which
|
|
231
|
+
* of them the folder loads (spec AST-081 FR12): those it uses, and the names
|
|
232
|
+
* of the integrations the folder loads itself, whose copies win.
|
|
233
|
+
* @param {string} cwd
|
|
234
|
+
* @returns {Promise<{computerIntegrations: import('../../foundation/integrations/computer-integrations.mjs').ComputerIntegrationCandidate[], loadedComputerIntegrations: string[], folderIntegrations: string[]}>}
|
|
235
|
+
*/
|
|
236
|
+
export async function computerIntegrationsOutside(cwd) {
|
|
237
|
+
const computerIntegrations = computerIntegrationCandidates(cwd);
|
|
238
|
+
if (computerIntegrations.length === 0) {
|
|
239
|
+
return {
|
|
240
|
+
computerIntegrations,
|
|
241
|
+
loadedComputerIntegrations: [],
|
|
242
|
+
folderIntegrations: [],
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
try {
|
|
246
|
+
const project = await Project.load(cwd, {core: 'project'});
|
|
247
|
+
/** @type {Array<{name: string, __computer?: boolean, __loadError?: string}>} */
|
|
248
|
+
const loaded = project.loadedIntegrations;
|
|
249
|
+
return {
|
|
250
|
+
computerIntegrations,
|
|
251
|
+
loadedComputerIntegrations: loaded
|
|
252
|
+
.filter(i => i.__computer && !i.__loadError)
|
|
253
|
+
.map(i => i.name),
|
|
254
|
+
folderIntegrations: loaded.filter(i => !i.__computer).map(i => i.name),
|
|
255
|
+
};
|
|
256
|
+
} catch {
|
|
257
|
+
return {
|
|
258
|
+
computerIntegrations,
|
|
259
|
+
loadedComputerIntegrations: [],
|
|
260
|
+
folderIntegrations: [],
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Inside a project: the integrations installed for the computer it could add
|
|
267
|
+
* (spec AST-081 FR12), leaving out every package it loads or declares.
|
|
268
|
+
* @param {string} cwd
|
|
269
|
+
* @param {string[]} loadedNames the integrations the project loads
|
|
270
|
+
* @returns {Promise<import('../../foundation/integrations/computer-integrations.mjs').ComputerIntegrationCandidate[]>}
|
|
271
|
+
*/
|
|
272
|
+
export async function computerIntegrationsToAdd(cwd, loadedNames) {
|
|
273
|
+
const installed = new Set([...loadedNames, ...declaredPackageNames(cwd)]);
|
|
274
|
+
return availableComputerIntegrations(cwd, installed);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* The package names the folder's package.json declares, nearest first.
|
|
279
|
+
* @param {string} cwd
|
|
280
|
+
* @returns {string[]}
|
|
281
|
+
*/
|
|
282
|
+
function declaredPackageNames(cwd) {
|
|
283
|
+
for (let dir = path.resolve(cwd); ;) {
|
|
284
|
+
if (fs.existsSync(path.join(dir, 'package.json'))) {
|
|
285
|
+
return readDeclaredDependencies(dir).map(d => d.name);
|
|
286
|
+
}
|
|
287
|
+
const parent = path.dirname(dir);
|
|
288
|
+
if (parent === dir) return [];
|
|
289
|
+
dir = parent;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* The computer-level agent text's setting and its state on disk.
|
|
295
|
+
* @returns {{settings: import('../../foundation/env/user-settings.mjs').ComputerAgentTextSettings, entries: Array<{path: string, state: import('../../foundation/agent-docs/computer-agent-text.mjs').ComputerAgentTextState, link?: true}>}}
|
|
296
|
+
*/
|
|
297
|
+
export function computerAgentTextState() {
|
|
298
|
+
const settings = computerAgentTextSettings();
|
|
299
|
+
return {settings, entries: inspectComputerAgentText({links: settings.links})};
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
export {displayHomePath};
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* The release facts doctor reports, read here so the checks stay pure
|
|
306
|
+
* (spec AST-081 FR5, FR6, FR10; architecture:cli-surface INV21): who
|
|
307
|
+
* answered, the newest release the computer knows of, how far the global copy
|
|
308
|
+
* or the project is behind, and every `astryx` on the search path with the
|
|
309
|
+
* command that upgrades it.
|
|
310
|
+
* @param {string} cwd
|
|
311
|
+
* @param {{project: boolean}} options
|
|
312
|
+
* @returns {{answeredBy: {cli: string, core: string | null, copy: string}, latest: string | null, globalBehind: ReturnType<typeof globalBehind> | null, projectLag: ReturnType<typeof projectLag> | null, lastNoticeSkip: ReturnType<typeof lastNoticeSkip>, lastCheckFailure: ReturnType<typeof lastCheckFailure>, stateLock: ReturnType<typeof stateLockHolder>, searchPathCommands: Array<import('../../foundation/env/search-path.mjs').SearchPathCommand & {upgrade: string | null}>}}
|
|
313
|
+
*/
|
|
314
|
+
export function releaseFacts(cwd, {project}) {
|
|
315
|
+
const answered = answeredBy(cwd);
|
|
316
|
+
return {
|
|
317
|
+
answeredBy: answered,
|
|
318
|
+
latest: knownLatestRelease(),
|
|
319
|
+
lastNoticeSkip: lastNoticeSkip(),
|
|
320
|
+
lastCheckFailure: lastCheckFailure(),
|
|
321
|
+
stateLock: stateLockHolder(),
|
|
322
|
+
globalBehind:
|
|
323
|
+
!project && isGlobalCopy(CLI_ROOT)
|
|
324
|
+
? globalBehind({self: {version: answered.cli, root: CLI_ROOT}})
|
|
325
|
+
: null,
|
|
326
|
+
// The project's version is its own CLI's, or, with none, its Core's:
|
|
327
|
+
// installed, else locked, else declared, as the daily notice reads it.
|
|
328
|
+
projectLag: project
|
|
329
|
+
? projectLag({
|
|
330
|
+
cwd,
|
|
331
|
+
current:
|
|
332
|
+
(answered.copy === 'starting' && projectCoreVersion(cwd)) ||
|
|
333
|
+
answered.cli,
|
|
334
|
+
})
|
|
335
|
+
: null,
|
|
336
|
+
searchPathCommands: astryxCommandsOnSearchPath().map(row => ({
|
|
337
|
+
...row,
|
|
338
|
+
upgrade: row.cliRoot ? globalUpgradeCommand(row.cliRoot) : null,
|
|
339
|
+
})),
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
/** Whether `cwd` is outside every project. */
|
|
344
|
+
export function outsideProject(/** @type {string} */ cwd) {
|
|
345
|
+
return isOutsideProject(cwd);
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* The commands that bring a project's own CLI and Core to one release, with
|
|
350
|
+
* the project's package manager: Core up to the CLI, then its codemods, when
|
|
351
|
+
* the CLI is newer; else the CLI to the Core's release.
|
|
352
|
+
* @param {string} cwd
|
|
353
|
+
* @param {string} cli
|
|
354
|
+
* @param {string} core
|
|
355
|
+
* @returns {string}
|
|
356
|
+
*/
|
|
357
|
+
export function alignCommand(cwd, cli, core) {
|
|
358
|
+
return alignCliAndCore({cwd, cli, core});
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* The Core release the project at `cwd` names: installed, else locked, else
|
|
363
|
+
* declared; the version the daily hint and notice compare against (spec
|
|
364
|
+
* AST-081 FR2). Null outside a project or when it names none.
|
|
365
|
+
* @param {string} cwd
|
|
366
|
+
* @returns {string | null}
|
|
367
|
+
*/
|
|
368
|
+
export function projectCoreVersion(cwd) {
|
|
369
|
+
return coreVersionOf(readReleaseFacts(cwd));
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
* Whether the project at `cwd` installs its own CLI (spec AST-081 FR2).
|
|
374
|
+
* @param {string} cwd
|
|
375
|
+
* @returns {boolean}
|
|
376
|
+
*/
|
|
377
|
+
export function projectHasOwnCli(cwd) {
|
|
378
|
+
return Boolean(readReleaseFacts(cwd).cli);
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
/**
|
|
382
|
+
* The command that adds the CLI at `version` with the project's package
|
|
383
|
+
* manager.
|
|
384
|
+
* @param {string} cwd
|
|
385
|
+
* @param {string} version
|
|
386
|
+
* @returns {string}
|
|
387
|
+
*/
|
|
388
|
+
export function addCliCommandFor(cwd, version) {
|
|
389
|
+
return addCliCommand(projectRootOf(readReleaseFacts(cwd)) ?? cwd, version);
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
/**
|
|
393
|
+
* The command that adds a package with the folder's package manager, read
|
|
394
|
+
* from its lockfiles and `packageManager` field.
|
|
395
|
+
* @param {string} cwd
|
|
396
|
+
* @returns {(name: string) => string}
|
|
397
|
+
*/
|
|
398
|
+
export function installCommandFor(cwd) {
|
|
399
|
+
const pm = detectPackageManager(cwd);
|
|
400
|
+
const verb =
|
|
401
|
+
pm === 'pnpm'
|
|
402
|
+
? 'pnpm add'
|
|
403
|
+
: pm === 'yarn'
|
|
404
|
+
? 'yarn add'
|
|
405
|
+
: pm === 'bun'
|
|
406
|
+
? 'bun add'
|
|
407
|
+
: 'npm install';
|
|
408
|
+
return name => `${verb} ${name}`;
|
|
409
|
+
}
|