@next-boilerplate/cli-helpers
Version:
CLI helper for Next Boilerplate
107 lines (104 loc) • 2.8 kB
text/typescript
import { z } from 'zod';
declare const storeConfigFileName = "config.json";
/**
* @description Regular expressions for validating store names and versions
* @example
* storeNameRegex.test('@my-scope/my-store') // true
* storeNameRegex.test('my-store') // true
* storeNameRegex.test('my-store@1.0.0') // false
*/
declare const storeNameRegex: RegExp;
/**
* @description Regular expression for validating store versions
* @example
* storeVersionRegex.test('1.0.0') // true
* storeVersionRegex.test('^1.0.0') // true
* storeVersionRegex.test('latest') // true
* storeVersionRegex.test('1.0.0-alpha') // true
*/
declare const storeVersionRegex: RegExp;
/**
* @description Regular expressions for validating an item with store, format: <store_name>@<version>/<item_path>
* Group 1: store name
* Group 2: store version
* Group 3: item path
* @example
* matchItem.test('@my-scope/my-store@1.0.0/my-item') // true
*/
declare const matchItem: RegExp;
/**
* Schema for validating store used in configuration file.
*/
declare const storeSchema: z.ZodObject<{
name: z.ZodString;
version: z.ZodString;
}, "strip", z.ZodTypeAny, {
name: string;
version: string;
}, {
name: string;
version: string;
}>;
/**
* Schema for validating the configuration of a store.
*/
declare const storeConfigSchema: z.ZodObject<{
name: z.ZodString;
version: z.ZodString;
}, "strip", z.ZodTypeAny, {
name: string;
version: string;
}, {
name: string;
version: string;
}>;
type TStoreConfig = z.infer<typeof storeConfigSchema>;
/**
* Schema with additional properties.
*/
declare const fullStoreSchema: z.ZodObject<z.objectUtil.extendShape<{
name: z.ZodString;
version: z.ZodString;
}, {
uid: z.ZodString;
fullPath: z.ZodString;
}>, "strip", z.ZodTypeAny, {
name: string;
version: string;
uid: string;
fullPath: string;
}, {
name: string;
version: string;
uid: string;
fullPath: string;
}>;
type TFullStoreConfig = z.infer<typeof fullStoreSchema>;
/**
* Get the UID of a store.
* @param store
* @returns
*/
declare const getStoreUID: (store: z.infer<typeof storeConfigSchema>) => string;
/**
* Get the UID of an item.
* @param item
* @returns
*/
declare const getItemUID: (item: {
name: string;
store: z.infer<typeof storeConfigSchema>;
}) => string;
/**
* Extract the store name and version from an item UID.
* @param itemUID
* @returns
*/
declare const extractItemUID: (itemUID: string) => {
store: {
name: string;
version: string;
};
name: string;
};
export { type TFullStoreConfig, type TStoreConfig, extractItemUID, fullStoreSchema, getItemUID, getStoreUID, matchItem, storeConfigFileName, storeConfigSchema, storeNameRegex, storeSchema, storeVersionRegex };