UNPKG

@micro-cli/shared-utils

Version:
137 lines (109 loc) 5.36 kB
export { default as chalk } from 'chalk'; export { default as semver } from 'semver'; export { default as clear } from 'clear'; export { execa } from 'execa'; import BabelCore, { PluginObj } from '@babel/core'; declare function exit(code: number): void; declare const compile: (templatePath: string, data: any) => Promise<unknown>; declare const writeToFile: (targetPath: string, result: any) => Promise<void>; declare const extendPackage: (oldReactPackage: any, addPackage: any) => any; /** * @description 通过判断当前目录下是否存在tsconfig.json,来判断是否是typescript项目 * @return {Promise<boolean>} 是否是typescript项目 */ declare const isTypescript: () => Promise<boolean>; /** * @description 通过判断当前目录下是否存在package.json,来判断是否是在根目录 * @return {Promise<boolean>} 是否在根目录 */ declare const isRoot: () => Promise<boolean>; /** * @description 判断当前项目是什么项目 * @return {Promise<'Vue'|'React'|'unknown'>} 项目名 */ declare const projectType: () => Promise<'Vue' | 'React' | 'unknown'>; declare const hasYarn: () => boolean; declare const hasPnpmVersionOrLater: (version: string) => boolean; declare const hasPnpm3OrLater: () => boolean; /** * @description:判断该用户是否安装过git * @returns : true | false */ declare const hasGit: () => boolean; /** * @description:判断当前目录下是否已经初始化git * @returns : true | false */ declare const hasProjectGit: (cwd: string) => boolean; declare const _default$e: (context: string) => {}; declare const errorLog: (text: string) => void; declare const successLog: (text: string) => void; declare const errorLogWithBg: (text: string) => void; declare const successLogWithBg: (text: string) => void; /** * @description 确保目录是正常,如果有相同名字的,则向用户询问是否覆盖 * @description 若覆盖,则执行覆盖操作并返回true;若不覆盖,则返回false */ declare const ensureDir: (path: string, options: { force?: string; }) => Promise<boolean>; /** * @description 确保文件是正常,如果有相同名字的,则向用户询问是否覆盖 * @description 若覆盖,则执行覆盖操作并返回true;若不覆盖,则返回false * @param {string} path * @param {object} options * @return {Promise<boolean>} */ declare const ensureFile: (path: string, options: { force?: string; }) => Promise<boolean>; declare const _default$d: (request: string, targetDir: string) => Promise<any>; interface Option$2 { kind: 'named' | 'default'; require: string; } interface OuterOptions { [K: string]: Option$2; } declare const _default$c: ({ types, template }: typeof BabelCore, outerOptions: OuterOptions) => PluginObj; declare const _default$b: (code: string, imports: Parameters<typeof _default$c>['1']) => string | null | undefined; /** * @description 删除联合类型中的undefined * @example 如 '1' | 2 | undefined, 则会返回 '1' | 2 */ declare type DeleteUndefinedInUnion<T> = T extends undefined ? never : T; interface Option$1 { className: string; statements: string[]; } declare const _default$a: ({ template, types }: typeof BabelCore, option: Option$1) => PluginObj; declare const _default$9: (code: string, option: Parameters<typeof _default$a>['1']) => string; /** * @param {string} code 代码 * @param {string} replaceValue 替换成的节点 * @description 替换某个元素内的节点 * @description 目前只能替换template */ declare const _default$8: (code: string, replaceValue: string) => string; declare const _default$7: ({ template, types }: typeof BabelCore, option: { value: string; }) => PluginObj; declare const _default$6: (code: string, rootOption: Parameters<typeof _default$7>['1']['value']) => string; /** * @description 返回项目所用的css预处理器 */ declare const _default$5: () => Promise<"less" | "sass" | "stylus" | undefined>; declare const _default$4: (fn: () => Promise<string>, message: string) => Promise<void>; declare const commandSpawn: (command: string, options: string[], { cwd }: { cwd: string; }) => Promise<string>; interface Option { statement: string; } declare const _default$3: ({ template }: typeof BabelCore, options: Option) => PluginObj; declare const _default$2: (code: string, imports: Parameters<typeof _default$c>['1'], hook: Parameters<typeof _default$3>['1']) => string; declare const _default$1: ({ template, types }: typeof BabelCore, options: { router: string; }) => PluginObj; declare const _default: (code: string, router: Parameters<typeof _default$1>['1']['router']) => string; export { DeleteUndefinedInUnion, commandSpawn, compile, ensureDir, ensureFile, errorLog, errorLogWithBg, exit, extendPackage, _default$5 as getCssPreProcessor, hasGit, hasPnpm3OrLater, hasPnpmVersionOrLater, hasProjectGit, hasYarn, _default$2 as injectHookInReact, _default$b as injectImportsToFile, _default$6 as injectRootOptionInVue, _default as injectRouterInReact, isRoot, isTypescript, _default$d as loadModule, projectType, _default$9 as replaceNodeInJSX, _default$8 as replaceNodeInVue, _default$e as resolvePkg, successLog, successLogWithBg, _default$4 as wrapLoading, writeToFile };