@astryxdesign/cli 0.1.6-canary.15dd282 → 0.1.6-canary.1b61ba6
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/package.json +13 -9
- package/src/api/template.mjs +1 -1
- package/src/codemods/__tests__/registry.test.mjs +1 -0
- package/src/codemods/registry.mjs +1 -0
- package/src/codemods/transforms/v0.1.7/__tests__/migrate-table-tableprops-to-direct-props.test.mjs +120 -0
- package/src/codemods/transforms/v0.1.7/index.mjs +19 -0
- package/src/codemods/transforms/v0.1.7/migrate-table-tableprops-to-direct-props.mjs +188 -0
- package/src/config.mjs +5 -14
- package/src/doc.mjs +27 -0
- package/src/doc.test.mjs +383 -0
- package/src/integration.mjs +4 -15
- package/src/lib/component-discovery.importpath.test.mjs +59 -0
- package/src/lib/component-discovery.mjs +15 -5
- package/src/lib/component-format.mjs +45 -13
- package/src/lib/component-format.test.mjs +95 -1
- package/src/lib/component-loader.mjs +104 -2
- package/src/lib/componentDocOverlay.test.mjs +111 -0
- package/src/lib/hook-format.mjs +8 -3
- package/src/schemas/doc-schema.mjs +226 -0
- package/src/schemas/template-schema.mjs +47 -0
- package/src/template.mjs +9 -67
- package/src/types/config.d.ts +11 -66
- package/src/types/doc.d.ts +23 -0
- package/src/types/integration.d.ts +7 -18
- package/src/types/template-api.d.ts +14 -50
package/src/template.mjs
CHANGED
|
@@ -1,73 +1,15 @@
|
|
|
1
1
|
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* @file Static template authoring API.
|
|
4
|
+
* @file Static template authoring API (public `@astryxdesign/cli/template`).
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
* `
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* template discovery runs the module's default export through
|
|
13
|
-
* {@link TemplateEnvelopeSchema} (see `loadModuleWithSchema`).
|
|
6
|
+
* The `createPageTemplate`/`createBlockTemplate` authoring helpers now live in
|
|
7
|
+
* `@astryxdesign/core/authoring` and are re-exported here so existing
|
|
8
|
+
* `@astryxdesign/cli/template` imports keep working. The Zod load-boundary
|
|
9
|
+
* schemas live in `./schemas/template-schema.mjs` (core-free) and are
|
|
10
|
+
* re-exported here for back-compat; internal hot-path code imports them from
|
|
11
|
+
* the schema module directly so it never depends on core's built `dist/`.
|
|
14
12
|
*/
|
|
15
13
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const PreviewSchema = z
|
|
19
|
-
.object({
|
|
20
|
-
image: z.string().optional(),
|
|
21
|
-
aspectRatio: z.string().optional(),
|
|
22
|
-
})
|
|
23
|
-
.strict();
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Shared authored-template shape. `type` is injected by the create* helpers,
|
|
27
|
-
* so authors never write it. Inline source/sourceFile are intentionally NOT
|
|
28
|
-
* part of v1 — a template's source is the required same-stem sibling file.
|
|
29
|
-
* Exported so integration template discovery can validate the stamped result.
|
|
30
|
-
*/
|
|
31
|
-
export const BaseTemplateSchema = z
|
|
32
|
-
.object({
|
|
33
|
-
name: z.string().min(1, 'name is required'),
|
|
34
|
-
description: z.string().min(1, 'description is required'),
|
|
35
|
-
category: z.string().optional(),
|
|
36
|
-
componentsUsed: z.array(z.string()).optional(),
|
|
37
|
-
preview: PreviewSchema.optional(),
|
|
38
|
-
})
|
|
39
|
-
.strict();
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* The metadata envelope integration template discovery validates: a stamped
|
|
43
|
-
* template doc. This is the LOAD-boundary contract — a hand-written plain
|
|
44
|
-
* object that matches this shape is accepted (discovery does not check "was it
|
|
45
|
-
* made by the factory", only the shape).
|
|
46
|
-
*/
|
|
47
|
-
export const TemplateEnvelopeSchema = BaseTemplateSchema.extend({
|
|
48
|
-
type: z.enum(['page', 'block']),
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Author an Astryx page template doc. Stamp-only: returns the def with
|
|
53
|
-
* `type: 'page'` injected. Validation happens at the load boundary.
|
|
54
|
-
*
|
|
55
|
-
* @template {import('./types/template-api').AstryxPageTemplateInput} T
|
|
56
|
-
* @param {T} def
|
|
57
|
-
* @returns {T & {type: 'page'}}
|
|
58
|
-
*/
|
|
59
|
-
export function createPageTemplate(def) {
|
|
60
|
-
return /** @type {T & {type: 'page'}} */ ({...def, type: 'page'});
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Author an Astryx block template doc. Stamp-only: returns the def with
|
|
65
|
-
* `type: 'block'` injected. Validation happens at the load boundary.
|
|
66
|
-
*
|
|
67
|
-
* @template {import('./types/template-api').AstryxBlockTemplateInput} T
|
|
68
|
-
* @param {T} def
|
|
69
|
-
* @returns {T & {type: 'block'}}
|
|
70
|
-
*/
|
|
71
|
-
export function createBlockTemplate(def) {
|
|
72
|
-
return /** @type {T & {type: 'block'}} */ ({...def, type: 'block'});
|
|
73
|
-
}
|
|
14
|
+
export {createPageTemplate, createBlockTemplate} from '@astryxdesign/core/authoring';
|
|
15
|
+
export {BaseTemplateSchema, TemplateEnvelopeSchema} from './schemas/template-schema.mjs';
|
package/src/types/config.d.ts
CHANGED
|
@@ -1,70 +1,15 @@
|
|
|
1
1
|
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* The config-authoring surface moved to `@astryxdesign/core/config` so an app's
|
|
5
|
+
* config file gets type feedback without depending on the CLI. Re-exported here
|
|
6
|
+
* so existing `@astryxdesign/cli/config` type imports keep resolving.
|
|
6
7
|
*/
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* A post-codemod hook. `buildCommand` receives the package directory and the
|
|
19
|
-
* list of files changed by codemods, and returns the command to run (or a
|
|
20
|
-
* nullish value to skip).
|
|
21
|
-
*/
|
|
22
|
-
export type PostCodemodHook = {
|
|
23
|
-
name?: string;
|
|
24
|
-
buildCommand: (ctx: {
|
|
25
|
-
packageDir: string;
|
|
26
|
-
files: string[];
|
|
27
|
-
}) =>
|
|
28
|
-
| PostCodemodCommand
|
|
29
|
-
| null
|
|
30
|
-
| undefined
|
|
31
|
-
| Promise<PostCodemodCommand | null | undefined>;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
/** A component XLE layout expressions can reference by name via `{hint}`. */
|
|
35
|
-
export interface XleComponent {
|
|
36
|
-
/** Import specifier the component is imported from, e.g. '@/components/KpiCard'. */
|
|
37
|
-
from: string;
|
|
38
|
-
/** Optional human description shown in tooling. */
|
|
39
|
-
description?: string;
|
|
40
|
-
/** Import as the module's default export instead of a named export. Defaults to false. */
|
|
41
|
-
default?: boolean;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/** User config exported from astryx.config.{ts,mjs,js}. */
|
|
45
|
-
export interface AstryxConfig {
|
|
46
|
-
/** Integration package names to load. */
|
|
47
|
-
integrations?: string[];
|
|
48
|
-
/** Where to file issues/feedback for this project. */
|
|
49
|
-
issuesUrl?: string;
|
|
50
|
-
/** Lifecycle hooks. */
|
|
51
|
-
hooks?: {
|
|
52
|
-
postCodemod?: PostCodemodHook[];
|
|
53
|
-
};
|
|
54
|
-
/**
|
|
55
|
-
* EXPERIMENTAL — shape may change and is not part of the stable config
|
|
56
|
-
* contract. Provisional home for features still being proven out.
|
|
57
|
-
*/
|
|
58
|
-
experimental?: {
|
|
59
|
-
/** Experimental XLE (layout expression) configuration. */
|
|
60
|
-
xle?: {
|
|
61
|
-
/**
|
|
62
|
-
* Register app-local components so XLE layout expressions can
|
|
63
|
-
* reference them by name via {hint}. Keyed by component name.
|
|
64
|
-
*/
|
|
65
|
-
components?: Record<string, XleComponent>;
|
|
66
|
-
};
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export declare function createConfig<T extends AstryxConfig>(config: T): T;
|
|
8
|
+
export type {
|
|
9
|
+
PostCodemodCommand,
|
|
10
|
+
PostCodemodHook,
|
|
11
|
+
XleComponent,
|
|
12
|
+
AstryxConfig,
|
|
13
|
+
} from '@astryxdesign/core/config';
|
|
14
|
+
|
|
15
|
+
export {createConfig} from '@astryxdesign/core/config';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The doc-authoring surface moved to `@astryxdesign/core/authoring`. Re-exported
|
|
5
|
+
* here so existing `@astryxdesign/cli/doc` type imports keep resolving. The Zod
|
|
6
|
+
* load-boundary schemas remain in the CLI (see `src/doc.mjs`).
|
|
7
|
+
*/
|
|
8
|
+
export type {
|
|
9
|
+
AstryxBaseDocInput,
|
|
10
|
+
AstryxPropInput,
|
|
11
|
+
AstryxParamInput,
|
|
12
|
+
AstryxReturnInput,
|
|
13
|
+
AstryxComponentDocInput,
|
|
14
|
+
AstryxFunctionDocInput,
|
|
15
|
+
AstryxGenericDocInput,
|
|
16
|
+
AstryxComponentDoc,
|
|
17
|
+
} from '@astryxdesign/core/authoring';
|
|
18
|
+
|
|
19
|
+
export {
|
|
20
|
+
createComponentDoc,
|
|
21
|
+
createFunctionDoc,
|
|
22
|
+
createDoc,
|
|
23
|
+
} from '@astryxdesign/core/authoring';
|
|
@@ -1,21 +1,14 @@
|
|
|
1
1
|
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* The integration-manifest authoring surface moved to
|
|
5
|
+
* `@astryxdesign/core/authoring`. `AstryxIntegration` and `createIntegration`
|
|
6
|
+
* are re-exported here so existing `@astryxdesign/cli/integration` type imports
|
|
7
|
+
* keep resolving. `AstryxIntegrationIssue` stays in the CLI — it is an internal
|
|
8
|
+
* validation type, not part of the authoring surface.
|
|
8
9
|
*/
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
components?: string;
|
|
12
|
-
/** Relative path to the templates root (resolved to absolute). */
|
|
13
|
-
templates?: string;
|
|
14
|
-
/** Relative path to the codemods root (resolved to absolute). */
|
|
15
|
-
codemods?: string;
|
|
16
|
-
/** Where to file issues/feedback for this integration. */
|
|
17
|
-
issuesUrl?: string;
|
|
18
|
-
}
|
|
10
|
+
export type {AstryxIntegration} from '@astryxdesign/core/authoring';
|
|
11
|
+
export {createIntegration} from '@astryxdesign/core/authoring';
|
|
19
12
|
|
|
20
13
|
/** An issue surfaced by an integration. */
|
|
21
14
|
export interface AstryxIntegrationIssue {
|
|
@@ -23,7 +16,3 @@ export interface AstryxIntegrationIssue {
|
|
|
23
16
|
severity: 'warning' | 'error';
|
|
24
17
|
message: string;
|
|
25
18
|
}
|
|
26
|
-
|
|
27
|
-
export declare function createIntegration<T extends AstryxIntegration>(
|
|
28
|
-
integration: T,
|
|
29
|
-
): T;
|
|
@@ -1,54 +1,18 @@
|
|
|
1
1
|
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
* `@astryxdesign/cli/template
|
|
6
|
-
*
|
|
7
|
-
* A template doc lives in a `<id>.doc.{ts,mjs,js}` file with a required
|
|
8
|
-
* same-stem sibling source file (`<id>.tsx`). The doc's `type` (page or
|
|
9
|
-
* block) — injected by the create* helpers — decides how the template is
|
|
10
|
-
* scaffolded; there is no `/pages` vs `/blocks` directory requirement.
|
|
4
|
+
* The template-authoring surface moved to `@astryxdesign/core/authoring`.
|
|
5
|
+
* Re-exported here so existing `@astryxdesign/cli/template` type imports keep
|
|
6
|
+
* resolving.
|
|
11
7
|
*/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
export
|
|
23
|
-
/** Human-readable template name. Required. */
|
|
24
|
-
name: string;
|
|
25
|
-
/** One-line description of what the template provides. Required. */
|
|
26
|
-
description: string;
|
|
27
|
-
/** Optional grouping/category label. */
|
|
28
|
-
category?: string;
|
|
29
|
-
/** Component display names the template composes. */
|
|
30
|
-
componentsUsed?: string[];
|
|
31
|
-
/** Optional preview metadata. */
|
|
32
|
-
preview?: AstryxTemplatePreview;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/** Input accepted by {@link createPageTemplate} (no `type` field). */
|
|
36
|
-
export type AstryxPageTemplateInput = AstryxTemplateInput;
|
|
37
|
-
/** Input accepted by {@link createBlockTemplate} (no `type` field). */
|
|
38
|
-
export type AstryxBlockTemplateInput = AstryxTemplateInput;
|
|
39
|
-
|
|
40
|
-
/** A validated page template doc. */
|
|
41
|
-
export type AstryxPageTemplate = AstryxTemplateInput & {type: 'page'};
|
|
42
|
-
/** A validated block template doc. */
|
|
43
|
-
export type AstryxBlockTemplate = AstryxTemplateInput & {type: 'block'};
|
|
44
|
-
|
|
45
|
-
/** A validated template doc (page or block). */
|
|
46
|
-
export type AstryxTemplate = AstryxPageTemplate | AstryxBlockTemplate;
|
|
47
|
-
|
|
48
|
-
export declare function createPageTemplate<T extends AstryxPageTemplateInput>(
|
|
49
|
-
def: T,
|
|
50
|
-
): T & {type: 'page'};
|
|
51
|
-
|
|
52
|
-
export declare function createBlockTemplate<T extends AstryxBlockTemplateInput>(
|
|
53
|
-
def: T,
|
|
54
|
-
): T & {type: 'block'};
|
|
8
|
+
export type {
|
|
9
|
+
AstryxTemplatePreview,
|
|
10
|
+
AstryxTemplateInput,
|
|
11
|
+
AstryxPageTemplateInput,
|
|
12
|
+
AstryxBlockTemplateInput,
|
|
13
|
+
AstryxPageTemplate,
|
|
14
|
+
AstryxBlockTemplate,
|
|
15
|
+
AstryxTemplate,
|
|
16
|
+
} from '@astryxdesign/core/authoring';
|
|
17
|
+
|
|
18
|
+
export {createPageTemplate, createBlockTemplate} from '@astryxdesign/core/authoring';
|