@batijs/core 0.0.286 → 0.0.288
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/dist/index.d.ts +47 -19
- package/dist/index.js +453 -453
- package/package.json +6 -6
package/dist/index.d.ts
CHANGED
|
@@ -28,6 +28,9 @@ type TransformerProps = {
|
|
|
28
28
|
meta: VikeMeta;
|
|
29
29
|
};
|
|
30
30
|
type Transformer = (props: TransformerProps) => unknown;
|
|
31
|
+
interface StringTransformer {
|
|
32
|
+
finalize(): string;
|
|
33
|
+
}
|
|
31
34
|
|
|
32
35
|
declare function transformAndFormat(code: string, meta: VikeMeta, options: {
|
|
33
36
|
filepath: string;
|
|
@@ -68,37 +71,62 @@ declare const markdown: {
|
|
|
68
71
|
italic: typeof italic;
|
|
69
72
|
};
|
|
70
73
|
|
|
71
|
-
declare function loadReadme({ readfile }: TransformerProps): Promise<Readme>;
|
|
72
|
-
declare function loadAsJson({ readfile, source, target }: TransformerProps): Promise<any>;
|
|
73
|
-
declare function loadAsMagicast<Exports extends object>({ readfile, source, target, }: TransformerProps): Promise<ProxifiedModule<Exports>>;
|
|
74
|
-
declare function loadRelativeFileAsMagicast<Exports extends object>(relativePath: string, meta: Pick<ImportMeta, "url">): Promise<ProxifiedModule<Exports>>;
|
|
75
|
-
declare function loadYaml({ readfile, source, target }: TransformerProps, options?: ParseOptions & DocumentOptions & SchemaOptions): Promise<Document.Parsed<yaml.Alias.Parsed, true> | Document.Parsed<yaml.Scalar.Parsed, true> | Document.Parsed<yaml.YAMLMap.Parsed<yaml.ParsedNode, yaml.ParsedNode | null>, true> | Document.Parsed<yaml.YAMLSeq.Parsed<yaml.ParsedNode>, true>>;
|
|
76
|
-
|
|
77
|
-
declare const keys: readonly ["dev", "build", "preview", "lint", "format", "deploy", "test"];
|
|
78
|
-
type Scripts = (typeof keys)[number];
|
|
79
|
-
type ValidScripts = Scripts | `${Scripts}:${string}`;
|
|
80
74
|
interface PackageJsonDeps {
|
|
81
75
|
dependencies?: Record<string, string>;
|
|
82
76
|
devDependencies?: Record<string, string>;
|
|
83
77
|
}
|
|
84
78
|
interface PackageJsonScripts {
|
|
85
|
-
scripts
|
|
79
|
+
scripts?: Record<string, string>;
|
|
86
80
|
}
|
|
87
81
|
interface PackageJsonScriptOption {
|
|
88
|
-
value
|
|
82
|
+
value: string;
|
|
89
83
|
/**
|
|
90
84
|
* Higher values have priority
|
|
91
85
|
*/
|
|
92
86
|
precedence: number;
|
|
93
87
|
warnIfReplaced?: boolean;
|
|
94
88
|
}
|
|
95
|
-
type PackageJsonScriptOptions =
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
declare
|
|
89
|
+
type PackageJsonScriptOptions = Record<string, {
|
|
90
|
+
value?: string;
|
|
91
|
+
precedence: number;
|
|
92
|
+
warnIfReplaced?: boolean;
|
|
93
|
+
}>;
|
|
94
|
+
type AllDependencies<U extends PackageJsonDeps> = keyof U["dependencies"] | keyof U["devDependencies"];
|
|
95
|
+
declare class PackageJsonTransformer<U extends PackageJsonDeps> implements StringTransformer {
|
|
96
|
+
protected static previousScripts: PackageJsonScriptOptions;
|
|
97
|
+
protected static forcedDependencies: Set<string>;
|
|
98
|
+
protected static dependenciesScriptsRelation: Map<string | symbol | number, Set<string>>;
|
|
99
|
+
protected pendingAddedDependencies: string[];
|
|
100
|
+
protected pendingReplacedScripts: string[];
|
|
101
|
+
protected packageJson: PackageJsonScripts & PackageJsonDeps;
|
|
102
|
+
protected scopedPackageJson: U;
|
|
103
|
+
constructor(packageJson: PackageJsonScripts & PackageJsonDeps, scopedPackageJson: U);
|
|
104
|
+
setScript(name: string, args: PackageJsonScriptOption, condition?: boolean): this;
|
|
105
|
+
removeScript(name: string, condition?: boolean): this;
|
|
106
|
+
addDependencies(newDeps: AllDependencies<U>[], condition?: boolean): this;
|
|
107
|
+
addDependencies(newDeps: AllDependencies<U>[], onlyUsedBy?: string[], condition?: boolean): this;
|
|
108
|
+
addDevDependencies(newDeps: AllDependencies<U>[], condition?: boolean): this;
|
|
109
|
+
addDevDependencies(newDeps: AllDependencies<U>[], onlyUsedBy?: string[], condition?: boolean): this;
|
|
110
|
+
finalize(): string;
|
|
111
|
+
/**
|
|
112
|
+
* For tests purpose only
|
|
113
|
+
* @internal
|
|
114
|
+
*/
|
|
115
|
+
static clear(): void;
|
|
116
|
+
private _onlyUsedBy;
|
|
117
|
+
private _addDependencies;
|
|
118
|
+
/**
|
|
119
|
+
* Instead of removing a previously added dep, use `onlyUsedBy` parameter when adding a dependency
|
|
120
|
+
*/
|
|
121
|
+
private removeDependency;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
declare function loadReadme({ readfile }: TransformerProps): Promise<Readme>;
|
|
125
|
+
declare function loadAsJson({ readfile, source, target }: TransformerProps): Promise<any>;
|
|
126
|
+
declare function loadPackageJson<U extends PackageJsonDeps>({ readfile, source, target }: TransformerProps, scopedPackageJson: U): Promise<PackageJsonTransformer<U>>;
|
|
127
|
+
declare function loadAsMagicast<Exports extends object>({ readfile, source, target, }: TransformerProps): Promise<ProxifiedModule<Exports>>;
|
|
128
|
+
declare function loadRelativeFileAsMagicast<Exports extends object>(relativePath: string, meta: Pick<ImportMeta, "url">): Promise<ProxifiedModule<Exports>>;
|
|
129
|
+
declare function loadYaml({ readfile, source, target }: TransformerProps, options?: ParseOptions & DocumentOptions & SchemaOptions): Promise<Document.Parsed<yaml.Alias.Parsed, true> | Document.Parsed<yaml.Scalar.Parsed, true> | Document.Parsed<yaml.YAMLMap.Parsed<yaml.ParsedNode, yaml.ParsedNode | null>, true> | Document.Parsed<yaml.YAMLSeq.Parsed<yaml.ParsedNode>, true>>;
|
|
102
130
|
|
|
103
131
|
declare function appendToEnv(envContent: string | undefined | null, key: string, value: unknown, comment?: string): string;
|
|
104
132
|
|
|
@@ -114,4 +142,4 @@ declare function getVersion(): {
|
|
|
114
142
|
semver: string[];
|
|
115
143
|
};
|
|
116
144
|
|
|
117
|
-
export { type ContentGetter, type FileContext,
|
|
145
|
+
export { type ContentGetter, type FileContext, Readme, type StringTransformer, type Transformer, type TransformerProps, type VikeMeta, appendToEnv, formatCode, getArgs, getVersion, loadAsJson, loadAsMagicast, loadPackageJson, loadReadme, loadRelativeFileAsMagicast, loadYaml, markdown, packageManager, parseReadme, transformAndFormat, withIcon };
|