@wp-typia/project-tools 0.24.3 → 0.24.4
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.
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Caller-owned error messages for full block name validation.
|
|
3
|
+
*/
|
|
4
|
+
export interface FullBlockNameDiagnostics {
|
|
5
|
+
/**
|
|
6
|
+
* Message returned when the candidate block name is empty.
|
|
7
|
+
*/
|
|
8
|
+
empty: () => string;
|
|
9
|
+
/**
|
|
10
|
+
* Message returned when the candidate is not `namespace/block-slug`.
|
|
11
|
+
*/
|
|
12
|
+
invalidFormat: () => string;
|
|
13
|
+
}
|
|
1
14
|
export interface WorkspaceBlockTargetName {
|
|
2
15
|
blockName: string;
|
|
3
16
|
blockSlug: string;
|
|
@@ -12,11 +25,11 @@ export interface WorkspaceBlockTargetDiagnostics {
|
|
|
12
25
|
* Validate a full `namespace/block-slug` block name.
|
|
13
26
|
*
|
|
14
27
|
* @param blockName Candidate block name.
|
|
15
|
-
* @param
|
|
28
|
+
* @param diagnostics CLI flag name or diagnostic builders for caller-owned UX.
|
|
16
29
|
* @returns The trimmed full block name.
|
|
17
30
|
* @throws {Error} When the block name is empty or not a full block name.
|
|
18
31
|
*/
|
|
19
|
-
export declare function assertFullBlockName(blockName: string,
|
|
32
|
+
export declare function assertFullBlockName(blockName: string, diagnostics: string | FullBlockNameDiagnostics): string;
|
|
20
33
|
/**
|
|
21
34
|
* Resolve a workspace block target from either `block-slug` or
|
|
22
35
|
* `namespace/block-slug` input while preserving caller-owned diagnostics.
|
|
@@ -1,20 +1,30 @@
|
|
|
1
1
|
import { normalizeBlockSlug } from "./scaffold-identifiers.js";
|
|
2
2
|
const FULL_BLOCK_NAME_PATTERN = /^[a-z0-9-]+\/[a-z0-9-]+$/u;
|
|
3
|
+
function resolveFullBlockNameDiagnostics(diagnostics) {
|
|
4
|
+
if (typeof diagnostics !== "string") {
|
|
5
|
+
return diagnostics;
|
|
6
|
+
}
|
|
7
|
+
return {
|
|
8
|
+
empty: () => `\`${diagnostics}\` requires a block name.`,
|
|
9
|
+
invalidFormat: () => `\`${diagnostics}\` must use <namespace/block-slug> format.`,
|
|
10
|
+
};
|
|
11
|
+
}
|
|
3
12
|
/**
|
|
4
13
|
* Validate a full `namespace/block-slug` block name.
|
|
5
14
|
*
|
|
6
15
|
* @param blockName Candidate block name.
|
|
7
|
-
* @param
|
|
16
|
+
* @param diagnostics CLI flag name or diagnostic builders for caller-owned UX.
|
|
8
17
|
* @returns The trimmed full block name.
|
|
9
18
|
* @throws {Error} When the block name is empty or not a full block name.
|
|
10
19
|
*/
|
|
11
|
-
export function assertFullBlockName(blockName,
|
|
20
|
+
export function assertFullBlockName(blockName, diagnostics) {
|
|
21
|
+
const messages = resolveFullBlockNameDiagnostics(diagnostics);
|
|
12
22
|
const trimmed = blockName.trim();
|
|
13
23
|
if (!trimmed) {
|
|
14
|
-
throw new Error(
|
|
24
|
+
throw new Error(messages.empty());
|
|
15
25
|
}
|
|
16
26
|
if (!FULL_BLOCK_NAME_PATTERN.test(trimmed)) {
|
|
17
|
-
throw new Error(
|
|
27
|
+
throw new Error(messages.invalidFormat());
|
|
18
28
|
}
|
|
19
29
|
return trimmed;
|
|
20
30
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { PATTERN_CATALOG_SCOPE_IDS, PATTERN_SECTION_ROLE_PATTERN, PATTERN_TAG_PATTERN, type PatternCatalogScope } from "./pattern-catalog.js";
|
|
2
|
+
import type { FullBlockNameDiagnostics } from "./block-targets.js";
|
|
2
3
|
export { ADD_KIND_IDS } from "./cli-add-kind-ids.js";
|
|
3
4
|
export type { AddKindId } from "./cli-add-kind-ids.js";
|
|
4
5
|
export { PATTERN_CATALOG_SCOPE_IDS, PATTERN_SECTION_ROLE_PATTERN, PATTERN_TAG_PATTERN, };
|
|
@@ -95,11 +96,14 @@ export interface RunAddVariationCommandOptions {
|
|
|
95
96
|
*
|
|
96
97
|
* @property cwd Working directory used to resolve the nearest official workspace.
|
|
97
98
|
* @property targetBlockName Full `namespace/block` name that receives the variation.
|
|
99
|
+
* @property targetBlockNameDiagnostics Optional diagnostics for positional target
|
|
100
|
+
* block names. Omitted callers keep legacy target diagnostics.
|
|
98
101
|
* @property variationName Human-entered variation name normalized into a slug.
|
|
99
102
|
*/
|
|
100
103
|
export interface RunAddCoreVariationCommandOptions {
|
|
101
104
|
cwd?: string;
|
|
102
105
|
targetBlockName: string;
|
|
106
|
+
targetBlockNameDiagnostics?: string | FullBlockNameDiagnostics;
|
|
103
107
|
variationName: string;
|
|
104
108
|
}
|
|
105
109
|
/**
|
|
@@ -13,7 +13,7 @@ import { type RunAddCoreVariationCommandOptions } from "./cli-add-shared.js";
|
|
|
13
13
|
* target block name is not full `namespace/block` form, or the generated file
|
|
14
14
|
* already exists.
|
|
15
15
|
*/
|
|
16
|
-
export declare function runAddCoreVariationCommand({ cwd, targetBlockName, variationName, }: RunAddCoreVariationCommandOptions): Promise<{
|
|
16
|
+
export declare function runAddCoreVariationCommand({ cwd, targetBlockName, targetBlockNameDiagnostics, variationName, }: RunAddCoreVariationCommandOptions): Promise<{
|
|
17
17
|
projectDir: string;
|
|
18
18
|
targetBlockName: string;
|
|
19
19
|
variationFile: string;
|
|
@@ -369,9 +369,9 @@ async function writeCoreVariationRegistry(projectDir, targetBlockName, textDomai
|
|
|
369
369
|
* target block name is not full `namespace/block` form, or the generated file
|
|
370
370
|
* already exists.
|
|
371
371
|
*/
|
|
372
|
-
export async function runAddCoreVariationCommand({ cwd = process.cwd(), targetBlockName, variationName, }) {
|
|
372
|
+
export async function runAddCoreVariationCommand({ cwd = process.cwd(), targetBlockName, targetBlockNameDiagnostics = "core-variation target", variationName, }) {
|
|
373
373
|
const workspace = resolveWorkspaceProject(cwd);
|
|
374
|
-
const resolvedTargetBlockName = assertFullBlockName(targetBlockName,
|
|
374
|
+
const resolvedTargetBlockName = assertFullBlockName(targetBlockName, targetBlockNameDiagnostics);
|
|
375
375
|
const variationSlug = assertValidGeneratedSlug("Core variation name", normalizeBlockSlug(variationName), CORE_VARIATION_USAGE);
|
|
376
376
|
const unknownCoreTargetWarning = getUnknownCoreVariationTargetWarning(resolvedTargetBlockName);
|
|
377
377
|
assertCoreVariationSlugIsNotRegistryIndex(variationSlug);
|