@spcsn/taro-helper 0.1.0

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.
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.chalk = void 0;
7
+ exports.terminalLink = terminalLink;
8
+ const ansi_escapes_1 = __importDefault(require("ansi-escapes"));
9
+ const chalk_1 = __importDefault(require("chalk"));
10
+ exports.chalk = chalk_1.default;
11
+ const supports_hyperlinks_1 = __importDefault(require("supports-hyperlinks"));
12
+ function terminalLink(text, url, { target = 'stdout', fallback } = {}) {
13
+ if (!supports_hyperlinks_1.default[target]) {
14
+ if (fallback === false)
15
+ return text;
16
+ return typeof fallback === 'function' ? fallback(text, url) : `${text} (\u200B${url}\u200B)`;
17
+ }
18
+ return ansi_escapes_1.default.link(text, url);
19
+ }
20
+ terminalLink.isSupported = supports_hyperlinks_1.default.stdout;
21
+ terminalLink.stderr = ((text, url, options = {}) => terminalLink(text, url, { target: 'stderr', ...options }));
22
+ terminalLink.stderr.isSupported = supports_hyperlinks_1.default.stderr;
23
+ //# sourceMappingURL=terminal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"terminal.js","sourceRoot":"","sources":["../src/terminal.ts"],"names":[],"mappings":";;;;;;AAyBgB,oCAAY;AAzB5B,gEAAuC;AACvC,kDAA0B;AAwBjB,gBAxBF,eAAK,CAwBE;AAvBd,8EAAqD;AAQrD,SAAS,YAAY,CAAC,IAAY,EAAE,GAAW,EAAE,EAAE,MAAM,GAAG,QAAQ,EAAE,QAAQ,KAA2B,EAAE;IACzG,IAAI,CAAC,6BAAkB,CAAC,MAAM,CAAC,EAAE,CAAC;QAChC,IAAI,QAAQ,KAAK,KAAK;YAAE,OAAO,IAAI,CAAC;QAEpC,OAAO,OAAO,QAAQ,KAAK,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,WAAW,GAAG,SAAS,CAAC;IAC/F,CAAC;IAED,OAAO,sBAAW,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;AACrC,CAAC;AAED,YAAY,CAAC,WAAW,GAAG,6BAAkB,CAAC,MAAM,CAAC;AACrD,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC,IAAY,EAAE,GAAW,EAAE,OAAO,GAAG,EAAE,EAAE,EAAE,CACjE,YAAY,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,EAAE,CAAC,CAAwB,CAAC;AACpF,YAAY,CAAC,MAAM,CAAC,WAAW,GAAG,6BAAkB,CAAC,MAAM,CAAC"}
@@ -0,0 +1,86 @@
1
+ import * as babel from '@babel/core';
2
+ import babelGenerator from '@babel/generator';
3
+ import * as babelParser from '@babel/parser';
4
+ import * as fs from 'fs-extra';
5
+ import { processTypeEnum } from './constants';
6
+ import type TResolve from 'resolve';
7
+ export declare function normalizePath(path: string): string;
8
+ export declare const isNodeModule: (filename: string) => boolean;
9
+ export declare function isNpmPkg(name: string): boolean;
10
+ export declare function isQuickAppPkg(name: string): boolean;
11
+ export declare function isAliasPath(name: string, pathAlias?: Record<string, any>): boolean;
12
+ export declare function replaceAliasPath(filePath: string, name: string, pathAlias?: Record<string, any>): string;
13
+ export declare function promoteRelativePath(fPath: string): string;
14
+ export declare function resolveStylePath(p: string): string;
15
+ export declare function printLog(type: processTypeEnum, tag: string, filePath?: string): void;
16
+ export declare function recursiveFindNodeModules(filePath: string, lastFindPath?: string): string;
17
+ export declare function getUserHomeDir(): string;
18
+ export declare function getTaroPath(): string;
19
+ export declare function getConfig(): Record<string, any>;
20
+ export declare function getHash(text: Buffer | string): string;
21
+ export declare function getSystemUsername(): string;
22
+ export declare function shouldUseYarn(): boolean;
23
+ export declare function shouldUseCnpm(): boolean;
24
+ export declare function isEmptyObject(obj: any): boolean;
25
+ export declare function resolveSync(id: string, opts?: TResolve.SyncOpts & {
26
+ mainFields?: string[];
27
+ }): string | null;
28
+ export declare function resolveMainFilePath(p: string, extArrs?: string[]): string;
29
+ export declare function resolveScriptPath(p: string): string;
30
+ export declare function generateEnvList(env: Record<string, any>): Record<string, any>;
31
+ /**
32
+ * 获取 npm 文件或者依赖的绝对路径
33
+ *
34
+ * @param {string} 参数 1 - 组件路径
35
+ * @param {string} 参数 2 - 文件扩展名
36
+ * @returns {string} npm 文件绝对路径
37
+ */
38
+ export declare function getNpmPackageAbsolutePath(npmPath: string, defaultFile?: string): string | null;
39
+ export declare function generateConstantsList(constants: Record<string, any>): Record<string, any>;
40
+ export declare function cssImports(content: string): string[];
41
+ export declare function emptyDirectory(dirPath: string, opts?: {
42
+ excludes: Array<string | RegExp> | string | RegExp;
43
+ }): void;
44
+ export declare const pascalCase: (str: string) => string;
45
+ export declare function getInstalledNpmPkgPath(pkgName: string, basedir: string): string | null;
46
+ export declare function getInstalledNpmPkgVersion(pkgName: string, basedir: string): string | null;
47
+ export declare const recursiveMerge: <T = any>(src: Partial<T>, ...args: (Partial<T> | undefined)[]) => any;
48
+ export declare const mergeVisitors: (src: any, ...args: any[]) => any;
49
+ export declare const applyArrayedVisitors: (obj: any) => any;
50
+ export declare const getAllFilesInFolder: (folder: string, filter?: string[]) => Promise<string[]>;
51
+ export interface FileStat {
52
+ name: string;
53
+ isDirectory: boolean;
54
+ isFile: boolean;
55
+ }
56
+ export declare function readDirWithFileTypes(folder: string): FileStat[];
57
+ export declare function extnameExpRegOf(filePath: string): RegExp;
58
+ export declare function addPlatforms(platform: string): void;
59
+ export declare const getModuleDefaultExport: (exports: any) => any;
60
+ export declare function removeHeadSlash(str: string): string;
61
+ export declare function readPageConfig(configPath: string): any;
62
+ interface IReadConfigOptions {
63
+ alias?: Record<string, any>;
64
+ defineConstants?: Record<string, any>;
65
+ }
66
+ export declare function readConfig<T extends IReadConfigOptions>(configPath: string, options?: T): any;
67
+ export declare function removePathPrefix(filePath?: string): string;
68
+ export { fs };
69
+ export declare const babelKit: {
70
+ types: typeof babel.types;
71
+ parse: typeof babelParser.parse;
72
+ generate: typeof babelGenerator;
73
+ traverse: {
74
+ <S>(parent: import("@babel/traverse").Node, opts: import("@babel/traverse").TraverseOptions<S>, scope: import("@babel/traverse").Scope | undefined, state: S, parentPath?: babel.NodePath): void;
75
+ (parent: import("@babel/traverse").Node, opts?: import("@babel/traverse").TraverseOptions, scope?: import("@babel/traverse").Scope, state?: any, parentPath?: babel.NodePath): void;
76
+ visitors: typeof import("@babel/traverse").visitors;
77
+ verify: typeof import("@babel/traverse").visitors.verify;
78
+ explode: typeof import("@babel/traverse").visitors.explode;
79
+ cheap: (node: import("@babel/traverse").Node, enter: (node: import("@babel/traverse").Node) => void) => void;
80
+ node: (node: import("@babel/traverse").Node, opts: import("@babel/traverse").TraverseOptions, scope?: import("@babel/traverse").Scope, state?: any, path?: babel.NodePath, skipKeys?: Record<string, boolean>) => void;
81
+ clearNode: (node: import("@babel/traverse").Node, opts?: import("@babel/traverse").RemovePropertiesOptions) => void;
82
+ removeProperties: (tree: import("@babel/traverse").Node, opts?: import("@babel/traverse").RemovePropertiesOptions) => import("@babel/traverse").Node;
83
+ hasType: (tree: import("@babel/traverse").Node, type: import("@babel/traverse").Node["type"], denylistTypes?: string[]) => boolean;
84
+ cache: typeof import("@babel/traverse").cache;
85
+ };
86
+ };