@astryxdesign/cli 0.6.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +48 -1
- package/README.md +76 -67
- package/api/build/build.test.mjs +37 -0
- package/api/build/build.type.mjs +1 -1
- package/api/build/kit/kit.mjs +31 -1
- package/api/component/_adapter.mjs +14 -28
- package/api/component/integration-import-agreement.test.mjs +318 -0
- package/api/doctor/doctor.d.mts +32 -3
- package/api/doctor/doctor.doc.mjs +2 -1
- package/api/doctor/doctor.mjs +97 -4
- package/api/doctor/doctor.test.mjs +90 -1
- package/api/gap-report/gap-report-worker.d.mts +4 -0
- package/api/gap-report/gap-report-worker.mjs +73 -0
- package/api/gap-report/gap-report.d.mts +81 -0
- package/api/gap-report/gap-report.doc.d.mts +9 -0
- package/api/gap-report/gap-report.doc.mjs +127 -0
- package/api/gap-report/gap-report.mjs +707 -0
- package/api/gap-report/gap-report.test.mjs +1210 -0
- package/api/gap-report/gap-report.type.d.mts +88 -0
- package/api/gap-report/gap-report.type.mjs +69 -0
- package/api/index.d.mts +8 -1
- package/api/index.mjs +24 -1
- package/api/integration/add-contribution.d.mts +44 -0
- package/api/integration/add-contribution.mjs +1160 -0
- package/api/integration/add-contribution.test.mjs +733 -0
- package/api/integration/add-helpers.d.mts +80 -0
- package/api/integration/add-helpers.mjs +333 -0
- package/api/integration/add-helpers.test.mjs +161 -0
- package/api/integration/add-theme.d.mts +10 -0
- package/api/integration/add-theme.mjs +332 -0
- package/api/integration/add-theme.test.mjs +194 -0
- package/api/integration/integration-authoring.type.d.mts +55 -0
- package/api/integration/integration-authoring.type.mjs +76 -0
- package/api/integration/integration-block-exports.test.mjs +4 -0
- package/api/integration/integrationAdd.doc.d.mts +5 -0
- package/api/integration/integrationAdd.doc.mjs +100 -0
- package/api/integration/integrationAddAgentDoc.doc.d.mts +5 -0
- package/api/integration/integrationAddAgentDoc.doc.mjs +49 -0
- package/api/integration/integrationAddCodemod.doc.d.mts +5 -0
- package/api/integration/integrationAddCodemod.doc.mjs +55 -0
- package/api/integration/integrationAddComponent.doc.d.mts +5 -0
- package/api/integration/integrationAddComponent.doc.mjs +49 -0
- package/api/integration/integrationAddDoc.doc.d.mts +5 -0
- package/api/integration/integrationAddDoc.doc.mjs +59 -0
- package/api/integration/integrationAddTemplate.doc.d.mts +5 -0
- package/api/integration/integrationAddTemplate.doc.mjs +55 -0
- package/api/integration/integrationAddTheme.doc.d.mts +5 -0
- package/api/integration/integrationAddTheme.doc.mjs +85 -0
- package/api/integration/integrationPackCheck.doc.d.mts +5 -0
- package/api/integration/integrationPackCheck.doc.mjs +35 -0
- package/api/integration/pack-check.d.mts +27 -0
- package/api/integration/pack-check.mjs +795 -0
- package/api/integration/pack-check.test.mjs +569 -0
- package/api/integration/pack-check.type.d.mts +45 -0
- package/api/integration/pack-check.type.mjs +56 -0
- package/api/integration/public-api.test.mjs +21 -0
- package/api/integration/validate-integration.mjs +221 -11
- package/api/integration/validate-integration.test.mjs +189 -5
- package/api/integration/validateIntegration.doc.mjs +2 -2
- package/api/json/index.ts +1 -0
- package/api/search/search.mjs +19 -1
- package/api/theme/_adapter.d.mts +26 -28
- package/api/theme/_adapter.mjs +101 -38
- package/api/theme/add/add.d.mts +2 -1
- package/api/theme/add/add.mjs +56 -20
- package/api/theme/add/add.test.mjs +1 -0
- package/api/theme/build/build.d.mts +25 -0
- package/api/theme/build/build.mjs +101 -70
- package/api/theme/build/build.test.mjs +77 -44
- package/api/theme/integration-themes.test.mjs +183 -0
- package/api/theme/list/list.d.mts +10 -2
- package/api/theme/list/list.mjs +31 -10
- package/api/theme/list/list.test.mjs +102 -23
- package/api/theme/listThemes.doc.d.mts +1 -5
- package/api/theme/listThemes.doc.mjs +6 -13
- package/api/theme/targets/targets.test.mjs +22 -8
- package/api/theme/theme.d.mts +1 -1
- package/api/theme/theme.mjs +1 -1
- package/api/theme/theme.type.d.mts +9 -0
- package/api/theme/theme.type.mjs +3 -1
- package/api/theme/themeAdd.doc.d.mts +1 -4
- package/api/theme/themeAdd.doc.mjs +31 -31
- package/api/theme/themeBuild.doc.mjs +1 -1
- package/api/theme/themeList.doc.d.mts +1 -4
- package/api/theme/themeList.doc.mjs +7 -15
- package/api/theme/themeListAvailable.doc.d.mts +8 -0
- package/api/theme/themeListAvailable.doc.mjs +57 -0
- package/api/theme/themeTargets.doc.mjs +21 -7
- package/api/upgrade/_adapter.d.mts +2 -0
- package/api/upgrade/_adapter.mjs +1 -0
- package/api/upgrade/registry/registry.d.mts +40 -0
- package/api/upgrade/registry/registry.mjs +1154 -0
- package/api/upgrade/registry/registry.test.mjs +826 -0
- package/api/upgrade/run/run.mjs +49 -8
- package/api/upgrade/status/status.d.mts +6 -4
- package/api/upgrade/status/status.mjs +26 -8
- package/api/upgrade/upgrade.d.mts +2 -2
- package/api/upgrade/upgrade.doc.mjs +33 -9
- package/api/upgrade/upgrade.mjs +34 -7
- package/api/upgrade/upgrade.test.mjs +198 -8
- package/api/upgrade/upgrade.type.d.mts +90 -1
- package/api/upgrade/upgrade.type.mjs +51 -2
- package/assets/docs/cli-integrations.doc.mjs +152 -28
- package/assets/docs/getting-started.doc.mjs +1 -1
- package/assets/docs/{shadcn-compatibility.doc.mjs → shadcn-compatibility.doc.draft.mjs} +23 -13
- package/assets/docs/styling.doc.mjs +3 -3
- package/assets/docs/theme.doc.dense.mjs +2 -2
- package/assets/docs/theme.doc.mjs +23 -13
- package/assets/docs/theme.doc.zh.mjs +1 -1
- package/assets/templates/blocks/components/BaseTypeahead/BaseTypeaheadCustomSearch.doc.mjs +2 -1
- package/assets/templates/blocks/components/BaseTypeahead/BaseTypeaheadCustomSearch.tsx +38 -12
- package/assets/templates/blocks/components/BaseTypeahead/BaseTypeaheadShowcase.doc.mjs +15 -0
- package/assets/templates/blocks/components/BaseTypeahead/BaseTypeaheadShowcase.tsx +87 -0
- package/assets/templates/blocks/components/BottomSheet/BottomSheetSwitcherReviewFlow.doc.mjs +23 -0
- package/assets/templates/blocks/components/BottomSheet/BottomSheetSwitcherReviewFlow.tsx +75 -0
- package/assets/templates/blocks/components/BreadcrumbItem/BreadcrumbItemShowcase.tsx +5 -19
- package/assets/templates/blocks/components/Center/CenterHorizontal.doc.mjs +3 -2
- package/assets/templates/blocks/components/Center/CenterHorizontal.tsx +4 -5
- package/assets/templates/blocks/components/Toast/ToastAction.tsx +2 -1
- package/assets/templates/blocks/components/Toast/ToastDeduplication.tsx +2 -1
- package/assets/templates/blocks/components/Toast/ToastDismiss.tsx +2 -1
- package/assets/templates/blocks/components/Toast/ToastShowcase.tsx +2 -1
- package/assets/templates/blocks/components/Toast/ToastStacking.tsx +2 -1
- package/assets/templates/blocks/components/Toast/ToastTypes.tsx +2 -1
- package/assets/templates/pages/dashboard/template.doc.mjs +2 -2
- package/assets/templates/pages/dashboard-alert-rail/template.doc.mjs +3 -2
- package/assets/templates/pages/dashboard-cohort-funnel/template.doc.mjs +3 -2
- package/assets/templates/pages/dashboard-comparison/template.doc.mjs +3 -3
- package/assets/templates/pages/dashboard-composition/template.doc.mjs +2 -2
- package/assets/templates/pages/dashboard-progress/template.doc.mjs +2 -2
- package/assets/templates/pages/dashboard-scorecard/template.doc.mjs +2 -2
- package/assets/templates/themes/butter/butterTheme.ts +3 -3
- package/assets/templates/themes/neutral/neutralTheme.ts +2 -2
- package/assets/templates/themes/stone/stoneTheme.ts +3 -3
- package/assets/theme.template.ts +4 -7
- package/authoring/config/config.doc.mjs +9 -1
- package/authoring/config/parse.d.mts +2 -0
- package/authoring/config/parse.mjs +28 -3
- package/authoring/config/parse.test.mjs +25 -3
- package/authoring/config/type.ts +3 -0
- package/authoring/doctypes/_schema.d.mts +3 -0
- package/authoring/doctypes/_schema.mjs +6 -1
- package/authoring/doctypes/base/type.ts +6 -6
- package/authoring/doctypes/component/component.doc.mjs +6 -0
- package/authoring/doctypes/component/type.ts +2 -0
- package/authoring/gap-report/parse.d.mts +63 -0
- package/authoring/gap-report/parse.mjs +121 -0
- package/authoring/gap-report/parse.test.mjs +172 -0
- package/authoring/gap-report/type.ts +107 -0
- package/authoring/index.d.mts +1 -0
- package/authoring/index.d.ts +12 -0
- package/authoring/index.mjs +4 -0
- package/authoring/integration/integration.doc.mjs +14 -2
- package/authoring/integration/parse.test.mjs +9 -4
- package/authoring/integration/schema.d.mts +2 -0
- package/authoring/integration/schema.mjs +1 -0
- package/authoring/integration/type.ts +23 -6
- package/authoring/shadcn/receipt.d.mts +219 -0
- package/authoring/shadcn/receipt.mjs +248 -0
- package/authoring/shadcn/receipt.test.mjs +187 -0
- package/authoring/shadcn/source-variants.d.mts +28 -0
- package/authoring/shadcn/source-variants.mjs +176 -0
- package/authoring/shadcn/source-variants.test.mjs +120 -0
- package/clients/cli/commands/build-theme.mjs +54 -19
- package/clients/cli/commands/build-theme.variants.test.mjs +15 -12
- package/clients/cli/commands/component/index.mjs +1 -1
- package/clients/cli/commands/docs.test.mjs +1 -0
- package/clients/cli/commands/doctor-integration.doc.mjs +1 -1
- package/clients/cli/commands/gap-report.doc.mjs +73 -0
- package/clients/cli/commands/gap-report.mjs +114 -0
- package/clients/cli/commands/gap-report.test.mjs +198 -0
- package/clients/cli/commands/import-hint-correctness.test.mjs +88 -0
- package/clients/cli/commands/integration-add.doc.mjs +88 -0
- package/clients/cli/commands/integration-authoring.test.mjs +177 -0
- package/clients/cli/commands/integration-pack.doc.mjs +34 -0
- package/clients/cli/commands/integration-real-world.test.mjs +618 -0
- package/clients/cli/commands/integration.doc.mjs +28 -0
- package/clients/cli/commands/integration.mjs +153 -0
- package/clients/cli/commands/theme-add.doc.mjs +11 -6
- package/clients/cli/commands/theme-list.doc.mjs +21 -5
- package/clients/cli/commands/theme-targets.behavior.test.mjs +19 -2
- package/clients/cli/commands/theme.doc.mjs +2 -2
- package/clients/cli/commands/upgrade.doc.mjs +17 -4
- package/clients/cli/commands/upgrade.mjs +12 -1
- package/clients/cli/commands/upgrade.test.mjs +41 -0
- package/clients/cli/index.mjs +5 -0
- package/clients/cli/lib/component-format.mjs +42 -26
- package/clients/cli/lib/component-format.test.mjs +34 -3
- package/clients/cli/lib/manifest.mjs +12 -0
- package/foundation/config/project-themes.test.mjs +127 -0
- package/foundation/config/project.d.mts +23 -4
- package/foundation/config/project.mjs +96 -9
- package/foundation/config/project.test.mjs +132 -6
- package/foundation/discovery/component-discovery.d.mts +36 -0
- package/foundation/discovery/component-discovery.mjs +96 -0
- package/foundation/discovery/theme-discovery.d.mts +39 -0
- package/foundation/discovery/theme-discovery.mjs +650 -0
- package/foundation/discovery/theme-discovery.test.mjs +375 -0
- package/foundation/discovery/theming-targets.d.mts +16 -0
- package/foundation/discovery/theming-targets.mjs +39 -3
- package/foundation/discovery/theming-targets.test.mjs +139 -0
- package/foundation/integrations/autolink.d.mts +96 -0
- package/foundation/integrations/autolink.mjs +265 -0
- package/foundation/integrations/autolink.test.mjs +430 -0
- package/foundation/integrations/contribution-inventory.d.mts +152 -0
- package/foundation/integrations/contribution-inventory.mjs +497 -0
- package/foundation/integrations/contribution-inventory.test.mjs +361 -0
- package/foundation/integrations/integrations.d.mts +73 -9
- package/foundation/integrations/integrations.mjs +158 -8
- package/foundation/integrations/integrations.test.mjs +152 -29
- package/foundation/integrations/manifest-writer.d.mts +56 -0
- package/foundation/integrations/manifest-writer.mjs +328 -0
- package/foundation/integrations/manifest-writer.test.mjs +229 -0
- package/foundation/integrations/validate-contributions.mjs +81 -6
- package/foundation/response/error-codes.d.mts +4 -1
- package/foundation/response/error-codes.doc.mjs +16 -1
- package/foundation/response/error-codes.mjs +10 -1
- package/foundation/response/response-types.doc.mjs +23 -2
- package/package.json +8 -1
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file `astryx integration add theme` — scaffold one valid source theme into
|
|
5
|
+
* an integration package, update its theme catalog, and declare the root on
|
|
6
|
+
* first use.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import * as fs from 'node:fs';
|
|
10
|
+
import * as path from 'node:path';
|
|
11
|
+
import {AstryxError} from '../error.mjs';
|
|
12
|
+
import {ERROR_CODES} from '../../foundation/response/error-codes.mjs';
|
|
13
|
+
import {
|
|
14
|
+
assertWithin,
|
|
15
|
+
PathSafetyError,
|
|
16
|
+
sanitizeName,
|
|
17
|
+
} from '../../foundation/fs/path-safety.mjs';
|
|
18
|
+
import {
|
|
19
|
+
discoverThemeCatalog,
|
|
20
|
+
THEME_MANIFEST_BASENAME,
|
|
21
|
+
} from '../../foundation/discovery/theme-discovery.mjs';
|
|
22
|
+
import {
|
|
23
|
+
findLocalIntegrationManifestOrNull,
|
|
24
|
+
IntegrationRootConflictError,
|
|
25
|
+
patchIntegrationRoot,
|
|
26
|
+
} from '../../foundation/integrations/manifest-writer.mjs';
|
|
27
|
+
import {loadManifestObject} from '../../foundation/integrations/integrations.mjs';
|
|
28
|
+
import {assertContributionVisible} from '../../foundation/integrations/contribution-inventory.mjs';
|
|
29
|
+
import {
|
|
30
|
+
applyWrites,
|
|
31
|
+
findPackageDir,
|
|
32
|
+
packageJsonUpdate,
|
|
33
|
+
projectPath,
|
|
34
|
+
} from './add-helpers.mjs';
|
|
35
|
+
|
|
36
|
+
const DEFAULT_THEMES_ROOT = './themes';
|
|
37
|
+
|
|
38
|
+
/** @param {string} slug */
|
|
39
|
+
function themeIdentity(slug) {
|
|
40
|
+
try {
|
|
41
|
+
sanitizeName(slug, {label: 'theme name'});
|
|
42
|
+
} catch (error) {
|
|
43
|
+
if (error instanceof PathSafetyError) {
|
|
44
|
+
throw new AstryxError(
|
|
45
|
+
error.message,
|
|
46
|
+
undefined,
|
|
47
|
+
ERROR_CODES.ERR_INVALID_ARGUMENT,
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
throw error;
|
|
51
|
+
}
|
|
52
|
+
if (!/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u.test(slug)) {
|
|
53
|
+
throw new AstryxError(
|
|
54
|
+
`Invalid theme name "${slug}": use lowercase kebab-case starting with a letter.`,
|
|
55
|
+
undefined,
|
|
56
|
+
ERROR_CODES.ERR_INVALID_ARGUMENT,
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
const identifier = slug.replace(/-([a-z0-9])/gu, (_, character) =>
|
|
60
|
+
character.toUpperCase(),
|
|
61
|
+
);
|
|
62
|
+
const displayName = slug
|
|
63
|
+
.split('-')
|
|
64
|
+
.map(part =>
|
|
65
|
+
part === 'y2k' ? 'Y2K' : part[0].toUpperCase() + part.slice(1),
|
|
66
|
+
)
|
|
67
|
+
.join(' ');
|
|
68
|
+
return {
|
|
69
|
+
slug,
|
|
70
|
+
displayName,
|
|
71
|
+
exportName: `${identifier}Theme`,
|
|
72
|
+
entry: `${identifier}Theme.ts`,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** @param {{slug: string, exportName: string}} identity */
|
|
77
|
+
function themeSource(identity) {
|
|
78
|
+
return `import {defineTheme} from '@astryxdesign/core/theme';\n\nexport const ${identity.exportName} = defineTheme({\n name: '${identity.slug}',\n});\n`;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Read the bytes back through the same integration-theme discovery seam Project
|
|
83
|
+
* uses. A write is not successful until the requested slug resolves.
|
|
84
|
+
* @param {string} packageDir
|
|
85
|
+
* @param {string} manifestFile
|
|
86
|
+
* @param {string} owner
|
|
87
|
+
* @param {string} slug
|
|
88
|
+
*/
|
|
89
|
+
async function verifyThemeContribution(packageDir, manifestFile, owner, slug) {
|
|
90
|
+
const manifest = await loadManifestObject(
|
|
91
|
+
manifestFile,
|
|
92
|
+
`Integration manifest ${path.basename(manifestFile)}`,
|
|
93
|
+
{fresh: true},
|
|
94
|
+
);
|
|
95
|
+
if (!manifest.themes) {
|
|
96
|
+
throw new Error('The themes root was not visible after writing.');
|
|
97
|
+
}
|
|
98
|
+
const themesRoot = assertWithin(manifest.themes, packageDir, {
|
|
99
|
+
label: 'themes root',
|
|
100
|
+
});
|
|
101
|
+
await assertContributionVisible(
|
|
102
|
+
{
|
|
103
|
+
name: owner,
|
|
104
|
+
themes: themesRoot,
|
|
105
|
+
},
|
|
106
|
+
'theme',
|
|
107
|
+
slug,
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Add one source theme to the local integration package.
|
|
113
|
+
* @param {string} name lowercase kebab-case theme slug
|
|
114
|
+
* @param {import('./integration-authoring.type.mjs').IntegrationAddThemeOptions} [options]
|
|
115
|
+
* @returns {Promise<import('./integration-authoring.type.mjs').IntegrationAddResponse>}
|
|
116
|
+
*/
|
|
117
|
+
export async function integrationAddTheme(name, options = {}) {
|
|
118
|
+
const {cwd = process.cwd(), dryRun = false} = options;
|
|
119
|
+
const packageDir = findPackageDir(cwd);
|
|
120
|
+
const packageFile = path.join(packageDir, 'package.json');
|
|
121
|
+
let pkg;
|
|
122
|
+
try {
|
|
123
|
+
pkg = JSON.parse(fs.readFileSync(packageFile, 'utf-8'));
|
|
124
|
+
} catch (error) {
|
|
125
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
126
|
+
throw new AstryxError(
|
|
127
|
+
`Cannot read package.json: ${message}`,
|
|
128
|
+
undefined,
|
|
129
|
+
ERROR_CODES.ERR_THEME_INVALID,
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
const owner = typeof pkg.name === 'string' ? pkg.name : '(local integration)';
|
|
133
|
+
const identity = themeIdentity(name);
|
|
134
|
+
let manifestFile;
|
|
135
|
+
let manifestExists;
|
|
136
|
+
/** @type {import('../../authoring/integration/type').AstryxIntegration} */
|
|
137
|
+
let manifest = {};
|
|
138
|
+
try {
|
|
139
|
+
const existingManifest = findLocalIntegrationManifestOrNull(packageDir);
|
|
140
|
+
manifestExists = existingManifest != null;
|
|
141
|
+
manifestFile =
|
|
142
|
+
existingManifest ?? path.join(packageDir, 'astryx.integration.mjs');
|
|
143
|
+
if (manifestExists) {
|
|
144
|
+
manifest = await loadManifestObject(
|
|
145
|
+
manifestFile,
|
|
146
|
+
`Integration manifest ${path.basename(manifestFile)}`,
|
|
147
|
+
{fresh: true},
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
} catch (error) {
|
|
151
|
+
throw new AstryxError(
|
|
152
|
+
error instanceof Error ? error.message : String(error),
|
|
153
|
+
undefined,
|
|
154
|
+
ERROR_CODES.ERR_THEME_INVALID,
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const rootPath = manifest.themes ?? DEFAULT_THEMES_ROOT;
|
|
159
|
+
let root;
|
|
160
|
+
try {
|
|
161
|
+
root = assertWithin(rootPath, packageDir, {label: 'themes root'});
|
|
162
|
+
} catch (error) {
|
|
163
|
+
if (error instanceof PathSafetyError) {
|
|
164
|
+
throw new AstryxError(
|
|
165
|
+
error.message,
|
|
166
|
+
undefined,
|
|
167
|
+
ERROR_CODES.ERR_PATH_TRAVERSAL,
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
throw error;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
let rootReceipt;
|
|
174
|
+
try {
|
|
175
|
+
rootReceipt = await patchIntegrationRoot(packageDir, 'themes', rootPath, {
|
|
176
|
+
dryRun: true,
|
|
177
|
+
createIfMissing: true,
|
|
178
|
+
});
|
|
179
|
+
} catch (error) {
|
|
180
|
+
if (error instanceof IntegrationRootConflictError) {
|
|
181
|
+
throw new AstryxError(
|
|
182
|
+
error.message,
|
|
183
|
+
undefined,
|
|
184
|
+
ERROR_CODES.ERR_INTEGRATION_ROOT_CONFLICT,
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
throw new AstryxError(
|
|
188
|
+
error instanceof Error ? error.message : String(error),
|
|
189
|
+
undefined,
|
|
190
|
+
ERROR_CODES.ERR_THEME_INVALID,
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
const themeDir = assertWithin(identity.slug, root, {
|
|
195
|
+
label: 'theme directory',
|
|
196
|
+
});
|
|
197
|
+
const sourceFile = assertWithin(identity.entry, themeDir, {
|
|
198
|
+
label: 'theme source file',
|
|
199
|
+
});
|
|
200
|
+
if (fs.existsSync(sourceFile)) {
|
|
201
|
+
throw new AstryxError(
|
|
202
|
+
`Refusing to overwrite existing file ${projectPath(path.relative(packageDir, sourceFile))}.`,
|
|
203
|
+
undefined,
|
|
204
|
+
ERROR_CODES.ERR_FILE_EXISTS,
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
const catalogFile = assertWithin(THEME_MANIFEST_BASENAME, root, {
|
|
209
|
+
label: 'theme catalog manifest',
|
|
210
|
+
});
|
|
211
|
+
/** @type {{version: 1, themes: Array<Record<string, unknown>>, [key: string]: unknown}} */
|
|
212
|
+
let catalog = {version: 1, themes: []};
|
|
213
|
+
/** @type {Buffer|null} */
|
|
214
|
+
let catalogOriginal = null;
|
|
215
|
+
if (fs.existsSync(catalogFile)) {
|
|
216
|
+
try {
|
|
217
|
+
catalogOriginal = fs.readFileSync(catalogFile);
|
|
218
|
+
catalog = JSON.parse(catalogOriginal.toString('utf-8'));
|
|
219
|
+
// The discovery seam is the schema/source-of-truth validator. The write
|
|
220
|
+
// plan carries catalogOriginal, so any concurrent change between this read
|
|
221
|
+
// and publish is refused rather than overwritten with this snapshot.
|
|
222
|
+
discoverThemeCatalog(root, owner);
|
|
223
|
+
} catch (error) {
|
|
224
|
+
throw new AstryxError(
|
|
225
|
+
error instanceof Error ? error.message : String(error),
|
|
226
|
+
undefined,
|
|
227
|
+
ERROR_CODES.ERR_THEME_INVALID,
|
|
228
|
+
);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
if (
|
|
232
|
+
catalog.themes.some(
|
|
233
|
+
theme =>
|
|
234
|
+
typeof theme.slug === 'string' &&
|
|
235
|
+
theme.slug.toLowerCase() === identity.slug.toLowerCase(),
|
|
236
|
+
)
|
|
237
|
+
) {
|
|
238
|
+
throw new AstryxError(
|
|
239
|
+
`Theme "${identity.slug}" already exists in ${projectPath(path.relative(packageDir, catalogFile))}.`,
|
|
240
|
+
undefined,
|
|
241
|
+
ERROR_CODES.ERR_FILE_EXISTS,
|
|
242
|
+
);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
catalog.themes.push({
|
|
246
|
+
slug: identity.slug,
|
|
247
|
+
displayName: identity.displayName,
|
|
248
|
+
description: `${identity.displayName} theme.`,
|
|
249
|
+
maintained: true,
|
|
250
|
+
entry: identity.entry,
|
|
251
|
+
exportName: identity.exportName,
|
|
252
|
+
files: [identity.entry],
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
/** @type {import('./add-helpers.mjs').WritePlan[]} */
|
|
256
|
+
const plans = [];
|
|
257
|
+
plans.push(
|
|
258
|
+
{path: sourceFile, contents: themeSource(identity), createOnly: true},
|
|
259
|
+
{
|
|
260
|
+
path: catalogFile,
|
|
261
|
+
contents: `${JSON.stringify(catalog, null, 2)}\n`,
|
|
262
|
+
createOnly: catalogOriginal == null,
|
|
263
|
+
expectedOriginal: catalogOriginal ?? undefined,
|
|
264
|
+
},
|
|
265
|
+
);
|
|
266
|
+
const packageUpdate = packageJsonUpdate(
|
|
267
|
+
packageFile,
|
|
268
|
+
rootPath,
|
|
269
|
+
path.basename(manifestFile),
|
|
270
|
+
);
|
|
271
|
+
if (packageUpdate != null) {
|
|
272
|
+
plans.push({
|
|
273
|
+
path: packageFile,
|
|
274
|
+
contents: packageUpdate.contents,
|
|
275
|
+
createOnly: false,
|
|
276
|
+
expectedOriginal: packageUpdate.expectedOriginal,
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
const writtenFiles = plans.map(plan =>
|
|
281
|
+
projectPath(path.relative(packageDir, plan.path)),
|
|
282
|
+
);
|
|
283
|
+
const manifestPath = projectPath(path.relative(packageDir, manifestFile));
|
|
284
|
+
|
|
285
|
+
if (!dryRun) {
|
|
286
|
+
let rollback = () => {};
|
|
287
|
+
try {
|
|
288
|
+
rollback = applyWrites(plans);
|
|
289
|
+
rootReceipt = await patchIntegrationRoot(packageDir, 'themes', rootPath, {
|
|
290
|
+
createIfMissing: true,
|
|
291
|
+
verify: () =>
|
|
292
|
+
verifyThemeContribution(
|
|
293
|
+
packageDir,
|
|
294
|
+
manifestFile,
|
|
295
|
+
owner,
|
|
296
|
+
identity.slug,
|
|
297
|
+
),
|
|
298
|
+
});
|
|
299
|
+
} catch (error) {
|
|
300
|
+
rollback();
|
|
301
|
+
if (error instanceof IntegrationRootConflictError) {
|
|
302
|
+
throw new AstryxError(
|
|
303
|
+
error.message,
|
|
304
|
+
undefined,
|
|
305
|
+
ERROR_CODES.ERR_INTEGRATION_ROOT_CONFLICT,
|
|
306
|
+
);
|
|
307
|
+
}
|
|
308
|
+
if (error instanceof AstryxError) throw error;
|
|
309
|
+
throw new AstryxError(
|
|
310
|
+
`Failed to write theme contribution: ${error instanceof Error ? error.message : String(error)}`,
|
|
311
|
+
undefined,
|
|
312
|
+
ERROR_CODES.ERR_WRITE_FAILED,
|
|
313
|
+
);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
if (rootReceipt.created && !writtenFiles.includes(manifestPath)) {
|
|
317
|
+
writtenFiles.push(manifestPath);
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
return {
|
|
321
|
+
type: 'integration.add',
|
|
322
|
+
data: {
|
|
323
|
+
kind: 'theme',
|
|
324
|
+
name: identity.slug,
|
|
325
|
+
root: rootReceipt,
|
|
326
|
+
manifest: manifestPath,
|
|
327
|
+
files: writtenFiles,
|
|
328
|
+
written: !dryRun,
|
|
329
|
+
dryRun,
|
|
330
|
+
},
|
|
331
|
+
};
|
|
332
|
+
}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
import {afterEach, beforeEach, describe, expect, it} from 'vitest';
|
|
4
|
+
import * as fs from 'node:fs';
|
|
5
|
+
import * as path from 'node:path';
|
|
6
|
+
import {integrationAddTheme} from './add-theme.mjs';
|
|
7
|
+
import {validateLocalIntegration} from './validate-integration.mjs';
|
|
8
|
+
|
|
9
|
+
let tmpDir;
|
|
10
|
+
|
|
11
|
+
function setup({
|
|
12
|
+
manifest = 'export default {};\n',
|
|
13
|
+
files = ['dist'],
|
|
14
|
+
includeFiles = true,
|
|
15
|
+
} = {}) {
|
|
16
|
+
/** @type {{name: string, version: string, files?: string[]}} */
|
|
17
|
+
const pkg = {name: '@acme/themes', version: '1.0.0'};
|
|
18
|
+
if (includeFiles) pkg.files = files;
|
|
19
|
+
fs.writeFileSync(
|
|
20
|
+
path.join(tmpDir, 'package.json'),
|
|
21
|
+
`${JSON.stringify(pkg, null, 2)}\n`,
|
|
22
|
+
);
|
|
23
|
+
fs.writeFileSync(path.join(tmpDir, 'astryx.integration.mjs'), manifest);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
beforeEach(() => {
|
|
27
|
+
tmpDir = fs.mkdtempSync(path.join(process.cwd(), '.astryx-add-theme-'));
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
afterEach(() => {
|
|
31
|
+
fs.rmSync(tmpDir, {recursive: true, force: true});
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
describe('integrationAddTheme', () => {
|
|
35
|
+
it('writes a valid source theme, catalog, root, package files entry, and receipt', async () => {
|
|
36
|
+
setup();
|
|
37
|
+
const result = await integrationAddTheme('ocean', {cwd: tmpDir});
|
|
38
|
+
|
|
39
|
+
expect(result).toEqual({
|
|
40
|
+
type: 'integration.add',
|
|
41
|
+
data: {
|
|
42
|
+
kind: 'theme',
|
|
43
|
+
name: 'ocean',
|
|
44
|
+
root: {path: './themes', created: true},
|
|
45
|
+
manifest: 'astryx.integration.mjs',
|
|
46
|
+
files: [
|
|
47
|
+
'themes/ocean/oceanTheme.ts',
|
|
48
|
+
'themes/manifest.json',
|
|
49
|
+
'package.json',
|
|
50
|
+
'astryx.integration.mjs',
|
|
51
|
+
],
|
|
52
|
+
written: true,
|
|
53
|
+
dryRun: false,
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
expect(
|
|
57
|
+
fs.readFileSync(path.join(tmpDir, 'themes/ocean/oceanTheme.ts'), 'utf-8'),
|
|
58
|
+
).toContain('export const oceanTheme = defineTheme');
|
|
59
|
+
expect(
|
|
60
|
+
JSON.parse(
|
|
61
|
+
fs.readFileSync(path.join(tmpDir, 'themes/manifest.json'), 'utf-8'),
|
|
62
|
+
),
|
|
63
|
+
).toMatchObject({
|
|
64
|
+
version: 1,
|
|
65
|
+
themes: [
|
|
66
|
+
{
|
|
67
|
+
slug: 'ocean',
|
|
68
|
+
entry: 'oceanTheme.ts',
|
|
69
|
+
exportName: 'oceanTheme',
|
|
70
|
+
files: ['oceanTheme.ts'],
|
|
71
|
+
},
|
|
72
|
+
],
|
|
73
|
+
});
|
|
74
|
+
expect(
|
|
75
|
+
fs.readFileSync(path.join(tmpDir, 'astryx.integration.mjs'), 'utf-8'),
|
|
76
|
+
).toContain("themes: './themes'");
|
|
77
|
+
expect(
|
|
78
|
+
JSON.parse(fs.readFileSync(path.join(tmpDir, 'package.json'), 'utf-8'))
|
|
79
|
+
.files,
|
|
80
|
+
).toEqual(['dist', 'themes', 'astryx.integration.mjs']);
|
|
81
|
+
expect((await validateLocalIntegration(tmpDir)).issues).toEqual([]);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it('dry-runs the identical receipt without writing anything', async () => {
|
|
85
|
+
setup();
|
|
86
|
+
const beforeManifest = fs.readFileSync(
|
|
87
|
+
path.join(tmpDir, 'astryx.integration.mjs'),
|
|
88
|
+
'utf-8',
|
|
89
|
+
);
|
|
90
|
+
const result = await integrationAddTheme('ocean', {
|
|
91
|
+
cwd: tmpDir,
|
|
92
|
+
dryRun: true,
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
expect(result.data.written).toBe(false);
|
|
96
|
+
expect(result.data.dryRun).toBe(true);
|
|
97
|
+
expect(result.data.root).toEqual({path: './themes', created: true});
|
|
98
|
+
expect(result.data.files).toContain('themes/ocean/oceanTheme.ts');
|
|
99
|
+
expect(fs.existsSync(path.join(tmpDir, 'themes'))).toBe(false);
|
|
100
|
+
expect(
|
|
101
|
+
fs.readFileSync(path.join(tmpDir, 'astryx.integration.mjs'), 'utf-8'),
|
|
102
|
+
).toBe(beforeManifest);
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
it('does not create package.json files when the package had no allowlist', async () => {
|
|
106
|
+
setup({includeFiles: false});
|
|
107
|
+
await integrationAddTheme('ocean', {cwd: tmpDir});
|
|
108
|
+
const pkg = JSON.parse(
|
|
109
|
+
fs.readFileSync(path.join(tmpDir, 'package.json'), 'utf-8'),
|
|
110
|
+
);
|
|
111
|
+
expect(pkg).not.toHaveProperty('files');
|
|
112
|
+
expect(pkg).not.toHaveProperty('exports');
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
it('uses an author-declared custom root without rewriting it', async () => {
|
|
116
|
+
setup({
|
|
117
|
+
manifest: `export default {themes: './src/themes'};\n`,
|
|
118
|
+
files: undefined,
|
|
119
|
+
});
|
|
120
|
+
fs.mkdirSync(path.join(tmpDir, 'src/themes'), {recursive: true});
|
|
121
|
+
const result = await integrationAddTheme('ocean', {cwd: tmpDir});
|
|
122
|
+
|
|
123
|
+
expect(result.data.root).toEqual({path: './src/themes', created: false});
|
|
124
|
+
expect(result.data.files).not.toContain('astryx.integration.mjs');
|
|
125
|
+
expect(
|
|
126
|
+
fs.existsSync(path.join(tmpDir, 'src/themes/ocean/oceanTheme.ts')),
|
|
127
|
+
).toBe(true);
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it('refuses an invalid existing catalog without changing its bytes', async () => {
|
|
131
|
+
setup();
|
|
132
|
+
fs.mkdirSync(path.join(tmpDir, 'themes'));
|
|
133
|
+
const catalog = path.join(tmpDir, 'themes', 'manifest.json');
|
|
134
|
+
fs.writeFileSync(catalog, '{not-json\n');
|
|
135
|
+
|
|
136
|
+
await expect(
|
|
137
|
+
integrationAddTheme('ocean', {cwd: tmpDir}),
|
|
138
|
+
).rejects.toMatchObject({code: 'ERR_THEME_INVALID'});
|
|
139
|
+
expect(fs.readFileSync(catalog, 'utf-8')).toBe('{not-json\n');
|
|
140
|
+
expect(fs.existsSync(path.join(tmpDir, 'themes', 'ocean'))).toBe(false);
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
it('refuses duplicate themes and existing source files', async () => {
|
|
144
|
+
setup();
|
|
145
|
+
await integrationAddTheme('ocean', {cwd: tmpDir});
|
|
146
|
+
await expect(
|
|
147
|
+
integrationAddTheme('ocean', {cwd: tmpDir}),
|
|
148
|
+
).rejects.toMatchObject({code: 'ERR_FILE_EXISTS'});
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
it.each(['../ocean', 'Ocean', 'ocean theme', '.ocean'])(
|
|
152
|
+
'refuses unsafe or noncanonical name %s',
|
|
153
|
+
async name => {
|
|
154
|
+
setup();
|
|
155
|
+
await expect(
|
|
156
|
+
integrationAddTheme(name, {cwd: tmpDir}),
|
|
157
|
+
).rejects.toMatchObject({
|
|
158
|
+
code: 'ERR_INVALID_ARGUMENT',
|
|
159
|
+
});
|
|
160
|
+
},
|
|
161
|
+
);
|
|
162
|
+
|
|
163
|
+
it('creates the integration manifest on the first add', async () => {
|
|
164
|
+
fs.writeFileSync(
|
|
165
|
+
path.join(tmpDir, 'package.json'),
|
|
166
|
+
JSON.stringify({name: 'plain', files: []}),
|
|
167
|
+
);
|
|
168
|
+
const result = await integrationAddTheme('ocean', {cwd: tmpDir});
|
|
169
|
+
|
|
170
|
+
expect(result.data.manifest).toBe('astryx.integration.mjs');
|
|
171
|
+
expect(
|
|
172
|
+
result.data.files.filter(file => file === result.data.manifest),
|
|
173
|
+
).toHaveLength(1);
|
|
174
|
+
expect(
|
|
175
|
+
fs.readFileSync(path.join(tmpDir, 'astryx.integration.mjs'), 'utf-8'),
|
|
176
|
+
).toContain("themes: './themes'");
|
|
177
|
+
expect(
|
|
178
|
+
JSON.parse(fs.readFileSync(path.join(tmpDir, 'package.json'), 'utf-8'))
|
|
179
|
+
.files,
|
|
180
|
+
).toEqual(['themes', 'astryx.integration.mjs']);
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
it('plans manifest creation without writing it under dry-run', async () => {
|
|
184
|
+
fs.writeFileSync(path.join(tmpDir, 'package.json'), '{"name":"plain"}\n');
|
|
185
|
+
const result = await integrationAddTheme('ocean', {
|
|
186
|
+
cwd: tmpDir,
|
|
187
|
+
dryRun: true,
|
|
188
|
+
});
|
|
189
|
+
expect(result.data.files).toContain('astryx.integration.mjs');
|
|
190
|
+
expect(fs.existsSync(path.join(tmpDir, 'astryx.integration.mjs'))).toBe(
|
|
191
|
+
false,
|
|
192
|
+
);
|
|
193
|
+
});
|
|
194
|
+
});
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// @generated by scripts/sync-api-types.mjs from the JSDoc in api/**/*.mjs.
|
|
2
|
+
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
|
+
|
|
4
|
+
export type IntegrationAddKind = "theme" | "component" | "doc" | "template" | "codemod" | "agent-doc";
|
|
5
|
+
export type IntegrationAddBaseOptions = {
|
|
6
|
+
cwd?: string | undefined;
|
|
7
|
+
dryRun?: boolean | undefined;
|
|
8
|
+
};
|
|
9
|
+
export type IntegrationAddComponentOptions = IntegrationAddBaseOptions;
|
|
10
|
+
export type IntegrationAddDocOptions = IntegrationAddBaseOptions & {
|
|
11
|
+
replaces?: string;
|
|
12
|
+
extends?: string;
|
|
13
|
+
};
|
|
14
|
+
export type IntegrationAddTemplateOptions = IntegrationAddBaseOptions & {
|
|
15
|
+
type?: "page" | "block";
|
|
16
|
+
};
|
|
17
|
+
export type IntegrationAddCodemodOptions = IntegrationAddBaseOptions & {
|
|
18
|
+
to: string;
|
|
19
|
+
};
|
|
20
|
+
export type IntegrationAddAgentDocOptions = IntegrationAddBaseOptions;
|
|
21
|
+
export type IntegrationAddThemeOptions = IntegrationAddBaseOptions;
|
|
22
|
+
/**
|
|
23
|
+
* Options for the generic `integrationAdd` dispatcher. Prefer a per-kind API
|
|
24
|
+
* when the contribution kind is known so the accepted options stay narrow.
|
|
25
|
+
*/
|
|
26
|
+
export type IntegrationAddOptions = {
|
|
27
|
+
cwd?: string | undefined;
|
|
28
|
+
dryRun?: boolean | undefined;
|
|
29
|
+
templateType?: "block" | "page" | undefined;
|
|
30
|
+
replaces?: string | undefined;
|
|
31
|
+
extends?: string | undefined;
|
|
32
|
+
to?: string | undefined;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* A contribution writer receipt. `files` contains every project-relative path
|
|
36
|
+
* written by this call, or every path that would be written under `dryRun`.
|
|
37
|
+
* `root` is null for contribution kinds that modify a manifest field rather
|
|
38
|
+
* than declaring a directory root (e.g. agent-doc).
|
|
39
|
+
*/
|
|
40
|
+
export type IntegrationAddResponse = {
|
|
41
|
+
type: "integration.add";
|
|
42
|
+
data: IntegrationAddData;
|
|
43
|
+
};
|
|
44
|
+
export type IntegrationAddData = {
|
|
45
|
+
kind: "theme" | "component" | "doc" | "template" | "codemod" | "agent-doc";
|
|
46
|
+
name: string;
|
|
47
|
+
root: {
|
|
48
|
+
path: string;
|
|
49
|
+
created: boolean;
|
|
50
|
+
} | null;
|
|
51
|
+
manifest: string;
|
|
52
|
+
files: string[];
|
|
53
|
+
written: boolean;
|
|
54
|
+
dryRun: boolean;
|
|
55
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file Typed requests and responses for integration authoring commands.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @typedef {'theme'|'component'|'doc'|'template'|'codemod'|'agent-doc'} IntegrationAddKind
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @typedef {object} IntegrationAddBaseOptions
|
|
13
|
+
* @property {string} [cwd]
|
|
14
|
+
* @property {boolean} [dryRun]
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/** @typedef {IntegrationAddBaseOptions} IntegrationAddComponentOptions */
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @typedef {IntegrationAddBaseOptions & {
|
|
21
|
+
* replaces?: string,
|
|
22
|
+
* extends?: string,
|
|
23
|
+
* }} IntegrationAddDocOptions
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* @typedef {IntegrationAddBaseOptions & {
|
|
28
|
+
* type?: 'page'|'block',
|
|
29
|
+
* }} IntegrationAddTemplateOptions
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* @typedef {IntegrationAddBaseOptions & {
|
|
34
|
+
* to: string,
|
|
35
|
+
* }} IntegrationAddCodemodOptions
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
/** @typedef {IntegrationAddBaseOptions} IntegrationAddAgentDocOptions */
|
|
39
|
+
/** @typedef {IntegrationAddBaseOptions} IntegrationAddThemeOptions */
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Options for the generic `integrationAdd` dispatcher. Prefer a per-kind API
|
|
43
|
+
* when the contribution kind is known so the accepted options stay narrow.
|
|
44
|
+
*
|
|
45
|
+
* @typedef {object} IntegrationAddOptions
|
|
46
|
+
* @property {string} [cwd]
|
|
47
|
+
* @property {boolean} [dryRun]
|
|
48
|
+
* @property {'page'|'block'} [templateType]
|
|
49
|
+
* @property {string} [replaces]
|
|
50
|
+
* @property {string} [extends]
|
|
51
|
+
* @property {string} [to]
|
|
52
|
+
*/
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* A contribution writer receipt. `files` contains every project-relative path
|
|
56
|
+
* written by this call, or every path that would be written under `dryRun`.
|
|
57
|
+
* `root` is null for contribution kinds that modify a manifest field rather
|
|
58
|
+
* than declaring a directory root (e.g. agent-doc).
|
|
59
|
+
*
|
|
60
|
+
* @typedef {object} IntegrationAddResponse
|
|
61
|
+
* @property {'integration.add'} type
|
|
62
|
+
* @property {IntegrationAddData} data
|
|
63
|
+
*/
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* @typedef {object} IntegrationAddData
|
|
67
|
+
* @property {'theme'|'component'|'doc'|'template'|'codemod'|'agent-doc'} kind
|
|
68
|
+
* @property {string} name
|
|
69
|
+
* @property {{path: string, created: boolean}|null} root
|
|
70
|
+
* @property {string} manifest
|
|
71
|
+
* @property {string[]} files
|
|
72
|
+
* @property {boolean} written
|
|
73
|
+
* @property {boolean} dryRun
|
|
74
|
+
*/
|
|
75
|
+
|
|
76
|
+
export {};
|
|
@@ -177,6 +177,10 @@ const CANONICAL = 'import(@acme/widgets/templates/Gauge/GaugeShowcase.tsx)';
|
|
|
177
177
|
const SPEC = '@acme/widgets/templates/Gauge/GaugeShowcase.tsx';
|
|
178
178
|
|
|
179
179
|
describe('integration block-template exports recipe', () => {
|
|
180
|
+
it('has at least one real resolver available', () => {
|
|
181
|
+
expect(TSC_BIN ?? ESBUILD_BIN).not.toBeNull();
|
|
182
|
+
});
|
|
183
|
+
|
|
180
184
|
it.runIf(TSC_BIN != null)(
|
|
181
185
|
`CANONICAL: exports {"./templates/*.tsx"} + ${CANONICAL} type-checks under bundler resolution`,
|
|
182
186
|
() => {
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// @generated by scripts/sync-api-types.mjs from the JSDoc in api/**/*.mjs.
|
|
2
|
+
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
|
+
|
|
4
|
+
/** @type {import('@astryxdesign/cli/authoring').FunctionDoc} */
|
|
5
|
+
export const doc: import("@astryxdesign/cli/authoring").FunctionDoc;
|