@astryxdesign/cli 0.7.15-canary.gea16e8d → 0.7.15

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.
Files changed (134) hide show
  1. package/CHANGELOG.md +353 -3
  2. package/README.md +63 -63
  3. package/api/build/_adapter.d.mts +4 -0
  4. package/api/build/_adapter.mjs +28 -2
  5. package/api/build/blocks/blocks.d.mts +10 -1
  6. package/api/build/blocks/blocks.mjs +84 -7
  7. package/api/build/build.mjs +6 -1
  8. package/api/build/tree.d.mts +4 -0
  9. package/api/build/tree.mjs +9 -2
  10. package/api/doctor/_adapter.d.mts +2 -1
  11. package/api/doctor/_adapter.mjs +6 -1
  12. package/api/doctor/doctor.mjs +2 -2
  13. package/api/doctor/theme-checks.mjs +56 -21
  14. package/api/integration/add-helpers.mjs +5 -0
  15. package/api/integration/add-theme.mjs +15 -110
  16. package/api/integration/validate-integration.mjs +17 -3
  17. package/api/integration/validateIntegration.doc.mjs +1 -1
  18. package/api/theme/_adapter.d.mts +37 -5
  19. package/api/theme/_adapter.mjs +363 -50
  20. package/api/theme/_fork.d.mts +90 -0
  21. package/api/theme/_fork.mjs +246 -0
  22. package/api/theme/build/build.d.mts +25 -1
  23. package/api/theme/build/build.mjs +352 -41
  24. package/api/theme/eject/eject.mjs +36 -15
  25. package/api/theme/list/list.mjs +3 -6
  26. package/api/theme/palette/generate/generator.d.mts +13 -0
  27. package/api/theme/palette/generate/generator.mjs +32 -2
  28. package/api/theme/targets/targets.mjs +10 -3
  29. package/api/theme/template/template.mjs +48 -2
  30. package/api/theme/theme.type.d.mts +8 -0
  31. package/api/theme/theme.type.mjs +5 -1
  32. package/api/theme/themeBuild.doc.mjs +2 -2
  33. package/api/theme/themeRemove.doc.mjs +5 -2
  34. package/api/theme/themeTemplate.doc.mjs +2 -2
  35. package/api/theme/themeUse.doc.mjs +8 -2
  36. package/api/theme-edit/_adapter.mjs +157 -36
  37. package/api/theme-edit/_catalog.d.mts +1 -6
  38. package/api/theme-edit/_catalog.mjs +5 -268
  39. package/api/theme-edit/_check.d.mts +3 -1
  40. package/api/theme-edit/_check.mjs +733 -308
  41. package/api/theme-edit/_color.d.mts +19 -0
  42. package/api/theme-edit/_color.mjs +277 -33
  43. package/api/theme-edit/_compiler.d.mts +1 -0
  44. package/api/theme-edit/_compiler.mjs +25 -0
  45. package/api/theme-edit/_context.d.mts +2 -0
  46. package/api/theme-edit/_context.mjs +83 -9
  47. package/api/theme-edit/_css.d.mts +84 -0
  48. package/api/theme-edit/_css.mjs +700 -0
  49. package/api/theme-edit/_edit.mjs +370 -85
  50. package/api/theme-edit/_how-commands.d.mts +5 -0
  51. package/api/theme-edit/_how-commands.mjs +20 -13
  52. package/api/theme-edit/_how-question.d.mts +29 -0
  53. package/api/theme-edit/_how-question.mjs +1573 -182
  54. package/api/theme-edit/_how.mjs +306 -22
  55. package/api/theme-edit/_overview.mjs +2 -7
  56. package/api/theme-edit/_palette.d.mts +27 -5
  57. package/api/theme-edit/_palette.mjs +231 -97
  58. package/api/theme-edit/_parts.d.mts +42 -10
  59. package/api/theme-edit/_parts.mjs +224 -69
  60. package/api/theme-edit/_preview-app.d.mts +8 -0
  61. package/api/theme-edit/_preview-app.mjs +549 -96
  62. package/api/theme-edit/_preview.d.mts +7 -16
  63. package/api/theme-edit/_preview.mjs +77 -84
  64. package/api/theme-edit/_project.d.mts +20 -1
  65. package/api/theme-edit/_project.mjs +43 -13
  66. package/api/theme-edit/_settings.d.mts +96 -20
  67. package/api/theme-edit/_settings.mjs +646 -141
  68. package/api/theme-edit/_tables.d.mts +18 -12
  69. package/api/theme-edit/_tables.mjs +144 -147
  70. package/api/theme-edit/theme-edit.type.d.mts +10 -1
  71. package/api/theme-edit/theme-edit.type.mjs +3 -1
  72. package/api/theme-edit/themeEditNew.doc.mjs +1 -1
  73. package/api/theme-edit/themeEditPreviewAdd.doc.mjs +1 -1
  74. package/api/theme-edit/themeEditPreviewApp.doc.mjs +1 -1
  75. package/api/theme-edit/themeEditPreviewList.doc.mjs +2 -2
  76. package/api/theme-edit/themeEditSet.doc.mjs +1 -1
  77. package/api/theme-edit/themeEditUndo.doc.mjs +1 -1
  78. package/assets/docs/tree/checks.doc.mjs +22 -1
  79. package/assets/docs/tree/publishing.doc.mjs +1 -0
  80. package/assets/docs.generated.json +2 -2
  81. package/assets/self-audit.generated.json +1 -1
  82. package/authoring/integration/integration.doc.mjs +8 -0
  83. package/authoring/integration/schema.d.mts +8 -0
  84. package/authoring/integration/schema.mjs +1 -0
  85. package/authoring/integration/type.ts +9 -0
  86. package/clients/cli/build-id.generated.json +1 -1
  87. package/clients/cli/commands/experimental/index.mjs +10 -10
  88. package/clients/cli/commands/experimental/theme.mjs +22 -3
  89. package/clients/cli/commands/experimental-theme-compile.doc.mjs +2 -2
  90. package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +3 -3
  91. package/clients/cli/commands/experimental-theme-preview-add.doc.mjs +1 -1
  92. package/clients/cli/commands/experimental-theme-preview-app.doc.mjs +1 -1
  93. package/clients/cli/commands/integration.mjs +8 -0
  94. package/clients/cli/commands/theme-build.doc.mjs +2 -2
  95. package/clients/cli/commands/theme-list.doc.mjs +1 -1
  96. package/clients/cli/commands/theme-template.doc.mjs +1 -1
  97. package/clients/cli/commands/theme.mjs +325 -48
  98. package/clients/cli/index.mjs +18 -3
  99. package/clients/cli/lib/cli-error.mjs +118 -3
  100. package/clients/cli/manifest.generated.json +1 -1
  101. package/foundation/config/project.mjs +34 -8
  102. package/foundation/config/theme-state.d.mts +16 -0
  103. package/foundation/config/theme-state.mjs +84 -13
  104. package/foundation/discovery/template-needs.d.mts +13 -0
  105. package/foundation/discovery/template-needs.mjs +30 -15
  106. package/foundation/discovery/theme-discovery.mjs +14 -2
  107. package/foundation/discovery/theme-imports.d.mts +16 -0
  108. package/foundation/discovery/theme-imports.mjs +30 -2
  109. package/foundation/doc-compiler/import.mjs +10 -4
  110. package/foundation/fs/gather-cache.mjs +82 -23
  111. package/foundation/fs/jiti-cache.d.mts +21 -0
  112. package/foundation/fs/jiti-cache.mjs +66 -0
  113. package/foundation/fs/module-loader.mjs +7 -2
  114. package/foundation/integrations/autolink.d.mts +1 -24
  115. package/foundation/integrations/autolink.mjs +7 -60
  116. package/foundation/integrations/declared-dependencies.d.mts +27 -0
  117. package/foundation/integrations/declared-dependencies.mjs +73 -0
  118. package/foundation/integrations/integrations.d.mts +8 -0
  119. package/foundation/integrations/integrations.mjs +4 -0
  120. package/foundation/integrations/may-have-integrations.d.mts +8 -0
  121. package/foundation/integrations/may-have-integrations.mjs +47 -0
  122. package/foundation/integrations/validate-contributions.d.mts +62 -1
  123. package/foundation/integrations/validate-contributions.mjs +452 -29
  124. package/foundation/release/cache.d.mts +21 -2
  125. package/foundation/release/cache.mjs +48 -8
  126. package/foundation/release/folder-lock.d.mts +7 -0
  127. package/foundation/release/folder-lock.mjs +60 -26
  128. package/foundation/release/lock-lease.d.mts +2 -1
  129. package/foundation/release/lock-lease.mjs +7 -2
  130. package/foundation/response/error-codes.doc.mjs +1 -1
  131. package/foundation/response/response-types.doc.mjs +5 -5
  132. package/package.json +6 -6
  133. package/api/theme-edit/_css-properties.d.mts +0 -10
  134. package/api/theme-edit/_css-properties.mjs +0 -556
@@ -0,0 +1,66 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file Where jiti keeps the code it transpiles from TypeScript (integration
5
+ * manifests, config files, codemods, TypeScript template docs).
6
+ * @input The per-user cache folder (foundation/env/user-dirs.mjs) and the
7
+ * private-folder check (foundation/env/private-dir.mjs).
8
+ * @output `jitiCacheOptions()`: the `fsCache` option for the CLI's jiti
9
+ * loaders: `{fsCache: <user cache>/jiti}` when that folder is the user's
10
+ * own and no one else can reach it; `{fsCache: false}` (transpiled in
11
+ * memory only) when it is not; `{}` (jiti's own default) where the system
12
+ * has no user ids (Windows), whose temp folder is the user's own.
13
+ * @position Read by module-loader.mjs, doc-compiler/import.mjs and
14
+ * gather-cache.mjs. jiti's default is a `jiti` folder in the system temp
15
+ * folder, which on Linux every account on a machine shares, and which the
16
+ * system empties from time to time: another account could leave transpiled
17
+ * code there under the name jiti looks for,
18
+ * and after each emptying every TypeScript file is transpiled again. jiti
19
+ * names each cached file for its source's path and checks a hash of its
20
+ * source content before using it, so an edited, upgraded or downgraded
21
+ * file is transpiled again wherever the cache is. A set JITI_FS_CACHE is
22
+ * jiti's own setting and left to jiti.
23
+ */
24
+
25
+ import * as fs from 'node:fs';
26
+ import * as path from 'node:path';
27
+ import {currentUid, isPrivateDir} from '../env/private-dir.mjs';
28
+ import {userCacheDir} from '../env/user-dirs.mjs';
29
+
30
+ /** @type {{fsCache?: string | false} | undefined} */
31
+ let options;
32
+
33
+ /**
34
+ * The per-user folder for jiti's transpiled code.
35
+ * @returns {string}
36
+ */
37
+ export function jitiCacheDir() {
38
+ return path.join(userCacheDir(), 'jiti');
39
+ }
40
+
41
+ /**
42
+ * The `fsCache` option for a jiti loader: the per-user folder, made (0700)
43
+ * on first use and used at once, while it is a real folder the user owns and
44
+ * no one else can reach (the kept catalogs' check). A folder that fails the
45
+ * check, or cannot be made, is not used and nothing is cached on disk. Where
46
+ * the system has no user ids (Windows) ownership cannot be checked, and jiti
47
+ * keeps its default, the user's own temp folder there. Worked out once per
48
+ * process.
49
+ * @returns {{fsCache?: string | false}}
50
+ */
51
+ export function jitiCacheOptions() {
52
+ if (options) return options;
53
+ options = {};
54
+ if (process.env.JITI_FS_CACHE !== undefined || currentUid() == null) {
55
+ return options;
56
+ }
57
+ options = {fsCache: false};
58
+ try {
59
+ const dir = jitiCacheDir();
60
+ if (!fs.existsSync(dir)) fs.mkdirSync(dir, {recursive: true, mode: 0o700});
61
+ if (isPrivateDir(dir)) options = {fsCache: dir};
62
+ } catch {
63
+ // No disk cache: every TypeScript file is transpiled in memory.
64
+ }
65
+ return options;
66
+ }
@@ -26,6 +26,7 @@ import {pathToFileURL} from 'node:url';
26
26
  import * as fs from 'node:fs';
27
27
  import {findPresentFiles} from './present-files.mjs';
28
28
  import {importUrl} from './import-url.mjs';
29
+ import {jitiCacheOptions} from './jiti-cache.mjs';
29
30
 
30
31
  export {findPresentFiles};
31
32
 
@@ -42,7 +43,7 @@ const requireFromHere = createRequire(import.meta.url);
42
43
  const createJiti = (...args) => requireFromHere('jiti').createJiti(...args);
43
44
  function getJiti() {
44
45
  if (!jitiInstance) {
45
- jitiInstance = createJiti(import.meta.url);
46
+ jitiInstance = createJiti(import.meta.url, jitiCacheOptions());
46
47
  }
47
48
  return jitiInstance;
48
49
  }
@@ -201,6 +202,7 @@ function isMissingPackageExport(error) {
201
202
  export async function importThemeArtifact(specifier, cwd) {
202
203
  let themeModule = path.join(cwd, 'package.json');
203
204
  const loader = createJiti(path.join(cwd, 'package.json'), {
205
+ ...jitiCacheOptions(),
204
206
  moduleCache: false,
205
207
  jsx: true,
206
208
  interopDefault: true,
@@ -232,7 +234,10 @@ export async function importThemeArtifact(specifier, cwd) {
232
234
  */
233
235
  async function importModule(file, fresh) {
234
236
  if (fresh && file.endsWith('.ts')) {
235
- return await createJiti(import.meta.url, {moduleCache: false}).import(file);
237
+ return await createJiti(import.meta.url, {
238
+ ...jitiCacheOptions(),
239
+ moduleCache: false,
240
+ }).import(file);
236
241
  }
237
242
  if (file.endsWith('.ts')) {
238
243
  return await getJiti().import(file);
@@ -1,20 +1,6 @@
1
1
  // @generated by scripts/sync-api-types.mjs from the JSDoc in foundation/**/*.mjs.
2
2
  // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
3
 
4
- /**
5
- * The dependency names this project declares, in field then declaration order,
6
- * each tagged with the field that declared it. A name declared twice keeps the
7
- * first field it appeared in.
8
- *
9
- * Only keys are read. See the file header for why values are never parsed.
10
- *
11
- * @param {string} projectDir directory holding the project's package.json
12
- * @returns {Array<{name: string, field: string}>}
13
- */
14
- export function readDeclaredDependencies(projectDir: string): Array<{
15
- name: string;
16
- field: string;
17
- }>;
18
4
  /**
19
5
  * @typedef {object} AutolinkCandidate
20
6
  * @property {string} spec
@@ -111,16 +97,6 @@ export function autolinkIntegrations({ projectDir, loaded, fresh, }: {
111
97
  fresh?: boolean | undefined;
112
98
  }): Promise<import("./integrations.mjs").LoadedIntegration[]>;
113
99
  export { resolveInstalledPackageDir };
114
- /**
115
- * package.json fields whose keys name a dependency this project installs.
116
- *
117
- * `peerDependencies` is deliberately absent: a peer is a requirement the
118
- * CONSUMER must satisfy, not something this project's install brings in, so a
119
- * peer that happens to be present is not a declaration that it belongs here.
120
- *
121
- * @type {readonly string[]}
122
- */
123
- export const DEPENDENCY_FIELDS: readonly string[];
124
100
  export type AutolinkCandidate = {
125
101
  spec: string;
126
102
  field: string;
@@ -133,3 +109,4 @@ export type AutolinkCandidate = {
133
109
  repeat?: boolean | undefined;
134
110
  };
135
111
  import { resolveInstalledPackageDir } from './installed-package.mjs';
112
+ export { DEPENDENCY_FIELDS, readDeclaredDependencies } from "./declared-dependencies.mjs";
@@ -41,68 +41,15 @@ import * as fs from 'node:fs';
41
41
  import * as path from 'node:path';
42
42
  import {findManifestPaths, loadIntegrations} from './integrations.mjs';
43
43
  import {resolveProviders} from './provider-resolution.mjs';
44
- import {
45
- isBarePackageName,
46
- resolveInstalledPackageDir,
47
- } from './installed-package.mjs';
44
+ import {resolveInstalledPackageDir} from './installed-package.mjs';
45
+ import {readDeclaredDependencies} from './declared-dependencies.mjs';
48
46
 
49
- export {resolveInstalledPackageDir};
50
-
51
- /**
52
- * package.json fields whose keys name a dependency this project installs.
53
- *
54
- * `peerDependencies` is deliberately absent: a peer is a requirement the
55
- * CONSUMER must satisfy, not something this project's install brings in, so a
56
- * peer that happens to be present is not a declaration that it belongs here.
57
- *
58
- * @type {readonly string[]}
59
- */
60
- export const DEPENDENCY_FIELDS = Object.freeze([
61
- 'dependencies',
62
- 'devDependencies',
63
- 'optionalDependencies',
64
- ]);
65
-
66
-
67
- /**
68
- * The dependency names this project declares, in field then declaration order,
69
- * each tagged with the field that declared it. A name declared twice keeps the
70
- * first field it appeared in.
71
- *
72
- * Only keys are read. See the file header for why values are never parsed.
73
- *
74
- * @param {string} projectDir directory holding the project's package.json
75
- * @returns {Array<{name: string, field: string}>}
76
- */
77
- export function readDeclaredDependencies(projectDir) {
78
- /** @type {Record<string, unknown>} */
79
- let pkg;
80
- try {
81
- pkg = JSON.parse(
82
- fs.readFileSync(path.join(projectDir, 'package.json'), 'utf-8'),
83
- );
84
- } catch {
85
- // No package.json, or unreadable/malformed — nothing is declared.
86
- return [];
87
- }
88
-
89
- /** @type {Array<{name: string, field: string}>} */
90
- const declared = [];
91
- const seen = new Set();
92
- for (const field of DEPENDENCY_FIELDS) {
93
- const entry = pkg?.[field];
94
- if (entry == null || typeof entry !== 'object' || Array.isArray(entry)) {
95
- continue;
96
- }
97
- for (const name of Object.keys(entry)) {
98
- if (seen.has(name) || !isBarePackageName(name)) continue;
99
- seen.add(name);
100
- declared.push({name, field});
101
- }
102
- }
103
- return declared;
104
- }
47
+ export {
48
+ DEPENDENCY_FIELDS,
49
+ readDeclaredDependencies,
50
+ } from './declared-dependencies.mjs';
105
51
 
52
+ export {resolveInstalledPackageDir};
106
53
 
107
54
  /**
108
55
  * Resolve a path through symlinks for identity comparison. pnpm links every
@@ -0,0 +1,27 @@
1
+ // @generated by scripts/sync-api-types.mjs from the JSDoc in foundation/**/*.mjs.
2
+ // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
+
4
+ /**
5
+ * The dependency names this project declares, in field then declaration order,
6
+ * each tagged with the field that declared it. A name declared twice keeps the
7
+ * first field it appeared in.
8
+ *
9
+ * Only keys are read; the file header says why values are never parsed.
10
+ *
11
+ * @param {string} projectDir directory holding the project's package.json
12
+ * @returns {Array<{name: string, field: string}>}
13
+ */
14
+ export function readDeclaredDependencies(projectDir: string): Array<{
15
+ name: string;
16
+ field: string;
17
+ }>;
18
+ /**
19
+ * package.json fields whose keys name a dependency this project installs.
20
+ *
21
+ * `peerDependencies` is deliberately absent: a peer is a requirement the
22
+ * CONSUMER must satisfy, not something this project's install brings in, so a
23
+ * peer that happens to be present is not a declaration that it belongs here.
24
+ *
25
+ * @type {readonly string[]}
26
+ */
27
+ export const DEPENDENCY_FIELDS: readonly string[];
@@ -0,0 +1,73 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file The dependencies a project's package.json declares, as autolinking
5
+ * (autolink.mjs) and the recorder's cheap integration check
6
+ * (may-have-integrations.mjs) read them. Built-ins and path helpers only,
7
+ * so it loads before anything heavy.
8
+ *
9
+ * The KEY, never the VALUE: `"@acme/legacy-ui": "npm:@acme/ui@0.1.22"` is a
10
+ * real, installed shape; so are `workspace:*`, `file:../lib`, `link:` and
11
+ * `catalog:`. None of them is a semver range, and none of them has to be
12
+ * parsed: the key is the directory name under node_modules, which is the only
13
+ * thing resolution needs. Identity still comes from the resolved package's own
14
+ * package.json `name`.
15
+ */
16
+
17
+ import * as fs from 'node:fs';
18
+ import * as path from 'node:path';
19
+ import {isBarePackageName} from './installed-package.mjs';
20
+
21
+ /**
22
+ * package.json fields whose keys name a dependency this project installs.
23
+ *
24
+ * `peerDependencies` is deliberately absent: a peer is a requirement the
25
+ * CONSUMER must satisfy, not something this project's install brings in, so a
26
+ * peer that happens to be present is not a declaration that it belongs here.
27
+ *
28
+ * @type {readonly string[]}
29
+ */
30
+ export const DEPENDENCY_FIELDS = Object.freeze([
31
+ 'dependencies',
32
+ 'devDependencies',
33
+ 'optionalDependencies',
34
+ ]);
35
+
36
+ /**
37
+ * The dependency names this project declares, in field then declaration order,
38
+ * each tagged with the field that declared it. A name declared twice keeps the
39
+ * first field it appeared in.
40
+ *
41
+ * Only keys are read; the file header says why values are never parsed.
42
+ *
43
+ * @param {string} projectDir directory holding the project's package.json
44
+ * @returns {Array<{name: string, field: string}>}
45
+ */
46
+ export function readDeclaredDependencies(projectDir) {
47
+ /** @type {Record<string, unknown>} */
48
+ let pkg;
49
+ try {
50
+ pkg = JSON.parse(
51
+ fs.readFileSync(path.join(projectDir, 'package.json'), 'utf-8'),
52
+ );
53
+ } catch {
54
+ // No package.json, or unreadable/malformed — nothing is declared.
55
+ return [];
56
+ }
57
+
58
+ /** @type {Array<{name: string, field: string}>} */
59
+ const declared = [];
60
+ const seen = new Set();
61
+ for (const field of DEPENDENCY_FIELDS) {
62
+ const entry = pkg?.[field];
63
+ if (entry == null || typeof entry !== 'object' || Array.isArray(entry)) {
64
+ continue;
65
+ }
66
+ for (const name of Object.keys(entry)) {
67
+ if (seen.has(name) || !isBarePackageName(name)) continue;
68
+ seen.add(name);
69
+ declared.push({name, field});
70
+ }
71
+ }
72
+ return declared;
73
+ }
@@ -137,6 +137,14 @@ export type LoadedIntegration = {
137
137
  */
138
138
  iconSets?: string | undefined;
139
139
  issuesUrl?: string | undefined;
140
+ /**
141
+ * the manifest's logo
142
+ * paths as written, relative to the package root
143
+ */
144
+ logo?: {
145
+ light: string;
146
+ dark?: string;
147
+ } | undefined;
140
148
  agentDocs?: {
141
149
  append?: readonly string[];
142
150
  } | undefined;
@@ -58,6 +58,8 @@ import {resolveProviders} from './provider-resolution.mjs';
58
58
  * @property {string} [themes]
59
59
  * @property {string} [iconSets] the manifest's `experimental.iconSets` root
60
60
  * @property {string} [issuesUrl]
61
+ * @property {{light: string, dark?: string}} [logo] the manifest's logo
62
+ * paths as written, relative to the package root
61
63
  * @property {{append?: readonly string[]}} [agentDocs]
62
64
  * @property {string} [cliCommand] the command this package's users run the
63
65
  * CLI with; read by the picker in foundation/env (see cli-command.mjs)
@@ -501,6 +503,7 @@ export async function loadLocalIntegration(packageDir, {fresh = false} = {}) {
501
503
  themes: resolveRoot(manifest.themes),
502
504
  iconSets: resolveRoot(manifest.experimental?.iconSets),
503
505
  issuesUrl: manifest.issuesUrl,
506
+ logo: manifest.logo,
504
507
  agentDocs: manifest.agentDocs,
505
508
  cliCommand: manifest.cliCommand,
506
509
  __cliCommandError: cliCommandError,
@@ -629,6 +632,7 @@ export async function loadIntegrations(
629
632
  themes: resolveRoot(manifest.themes),
630
633
  iconSets: resolveRoot(manifest.experimental?.iconSets),
631
634
  issuesUrl: manifest.issuesUrl,
635
+ logo: manifest.logo,
632
636
  agentDocs: manifest.agentDocs,
633
637
  cliCommand: manifest.cliCommand,
634
638
  __cliCommandError: cliCommandError,
@@ -0,0 +1,8 @@
1
+ // @generated by scripts/sync-api-types.mjs from the JSDoc in foundation/**/*.mjs.
2
+ // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
+
4
+ /**
5
+ * @param {string} cwd
6
+ * @returns {boolean}
7
+ */
8
+ export function mayHaveIntegrations(cwd: string): boolean;
@@ -0,0 +1,47 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file Whether a project may load an integration, decided from a few file
5
+ * checks before anything heavy loads.
6
+ * @input The working folder.
7
+ * @output `mayHaveIntegrations(cwd)`: false only when the project root (the
8
+ * nearest package.json's folder, else `cwd`) has no Astryx config, is no
9
+ * integration itself, declares no installed dependency that ships an
10
+ * integration manifest, and the run is inside a project (outside one, the
11
+ * integrations installed beside the running CLI load, spec AST-081 FR12),
12
+ * so no configured, self-resolved, autolinked or computer-level integration
13
+ * can load.
14
+ * @position Read by foundation/fs/gather-cache.mjs: `component`, `template`,
15
+ * `theme` and `discover` record a run only for their integrations' kept
16
+ * check results, so a project with none skips the recorder entirely. A true
17
+ * answer only means the run records, so a check that says true too often
18
+ * costs time, never an answer.
19
+ */
20
+
21
+ import {CONFIG_BASENAMES} from '../config/config-path.mjs';
22
+ import {isOutsideProject} from '../env/project-scope.mjs';
23
+ import {findPackageRoot} from '../fs/paths.mjs';
24
+ import {findPresentFiles} from '../fs/present-files.mjs';
25
+ import {readDeclaredDependencies} from './declared-dependencies.mjs';
26
+ import {resolveInstalledPackageDir} from './installed-package.mjs';
27
+ import {MANIFEST_BASENAMES} from './manifest-paths.mjs';
28
+
29
+ /**
30
+ * @param {string} cwd
31
+ * @returns {boolean}
32
+ */
33
+ export function mayHaveIntegrations(cwd) {
34
+ const root = findPackageRoot(cwd) ?? cwd;
35
+ if (findPresentFiles(root, CONFIG_BASENAMES).length > 0) return true;
36
+ if (findPresentFiles(root, MANIFEST_BASENAMES).length > 0) return true;
37
+ for (const {name} of readDeclaredDependencies(root)) {
38
+ const installed = resolveInstalledPackageDir(name, root);
39
+ if (
40
+ installed &&
41
+ findPresentFiles(installed.packageDir, MANIFEST_BASENAMES).length > 0
42
+ ) {
43
+ return true;
44
+ }
45
+ }
46
+ return isOutsideProject(cwd);
47
+ }
@@ -124,8 +124,12 @@ export function negatedFilesEntry(rel: string, files: unknown): string | null;
124
124
  * package (`npm pack --dry-run`). When npm cannot answer, an asset no
125
125
  * `files` entry can reach is still a note, and any other is returned in
126
126
  * `unchecked`.
127
+ * It also returns `examples`, what the package-level listing note needs:
128
+ * whether any block is a showcase, and, when none is, how many components
129
+ * need an example (the exemptions above apply). It is absent when the
130
+ * templates or components cannot be read, so no listing note is drawn.
127
131
  * @param {LoadedIntegration} integration
128
- * @returns {Promise<{notes: Note[], unchecked: Array<{file: string, asset: string, reason: string}>}>}
132
+ * @returns {Promise<{notes: Note[], unchecked: Array<{file: string, asset: string, reason: string}>, examples?: ExampleSummary}>}
129
133
  */
130
134
  export function componentExamplesCheck(integration: LoadedIntegration): Promise<{
131
135
  notes: Note[];
@@ -134,6 +138,7 @@ export function componentExamplesCheck(integration: LoadedIntegration): Promise<
134
138
  asset: string;
135
139
  reason: string;
136
140
  }>;
141
+ examples?: ExampleSummary;
137
142
  }>;
138
143
  /**
139
144
  * The component doc names the check could not judge, shaped like the doc type
@@ -192,6 +197,49 @@ export function validateLoadedIntegrationListed(loaded: LoadedIntegration): Prom
192
197
  issues: Issue[];
193
198
  listed: Issue[];
194
199
  }>;
200
+ /**
201
+ * Whether these bytes are an image a catalog can show as a logo, in the
202
+ * format the file's extension names: `.png`, `.jpg` or `.jpeg`, `.webp`, or
203
+ * `.svg` drawn only with shapes; at most 512 KB. A file whose bytes claim
204
+ * another format, or any other extension, is refused.
205
+ * @param {Buffer} bytes
206
+ * @param {string} file the image's path or name
207
+ * @returns {boolean}
208
+ */
209
+ export function isListingImage(bytes: Buffer, file: string): boolean;
210
+ /**
211
+ * What `componentExamplesCheck` found that the package-level note needs.
212
+ * @typedef {object} ExampleSummary
213
+ * @property {number} needed components that need an example and have none
214
+ * @property {boolean} showcase whether any block template is a showcase
215
+ */
216
+ /**
217
+ * What a catalog needs to list the package well, as two information-only
218
+ * notes that fail no check under any flag, each with its fix:
219
+ * - `package_without_logo`: the integration file's `logo.light` (or, when
220
+ * the integration file has no `logo`, package.json `marketplace.logo.light`)
221
+ * names no image the package ships: missing, outside the package, not a
222
+ * file, not a PNG, JPEG, WebP or shapes-only SVG of at most 512 KB, or left
223
+ * out of the packed files. `dark`, when set, is checked the same way.
224
+ * - `package_without_example`: from `examples`, the summary
225
+ * `componentExamplesCheck` returns: the package has components that need
226
+ * an example and no block template is a showcase. A package of themes,
227
+ * docs, codemods or agent docs alone needs none.
228
+ * A package of icon sets alone draws neither note. When npm cannot say
229
+ * whether a logo is packed, it is returned in `unchecked`, listed with the
230
+ * template assets npm could not place.
231
+ * @param {LoadedIntegration} integration
232
+ * @param {ExampleSummary} [examples]
233
+ * @returns {{notes: Note[], unchecked: Array<{file: string, asset: string, reason: string}>}}
234
+ */
235
+ export function packageListingCheck(integration: LoadedIntegration, examples?: ExampleSummary): {
236
+ notes: Note[];
237
+ unchecked: Array<{
238
+ file: string;
239
+ asset: string;
240
+ reason: string;
241
+ }>;
242
+ };
195
243
  /**
196
244
  * @typedef {import('./issue').AstryxIntegrationIssue} Issue
197
245
  * @typedef {import('./integrations.mjs').LoadedIntegration} LoadedIntegration
@@ -210,5 +258,18 @@ export type Note = {
210
258
  code: string;
211
259
  message: string;
212
260
  };
261
+ /**
262
+ * What `componentExamplesCheck` found that the package-level note needs.
263
+ */
264
+ export type ExampleSummary = {
265
+ /**
266
+ * components that need an example and have none
267
+ */
268
+ needed: number;
269
+ /**
270
+ * whether any block template is a showcase
271
+ */
272
+ showcase: boolean;
273
+ };
213
274
  export type Issue = import("./issue").AstryxIntegrationIssue;
214
275
  export type LoadedIntegration = import("./integrations.mjs").LoadedIntegration;