einsteinjs 0.1.3 → 0.1.5
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 +12 -1
- package/dist/index.js +32 -8
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -97,7 +97,18 @@ interface Config {
|
|
|
97
97
|
*/
|
|
98
98
|
declare function defineConfig(config: Config): Config;
|
|
99
99
|
|
|
100
|
-
|
|
100
|
+
/**
|
|
101
|
+
* API pública.
|
|
102
|
+
*
|
|
103
|
+
* Permite:
|
|
104
|
+
*
|
|
105
|
+
* await build(
|
|
106
|
+
* tsx,
|
|
107
|
+
* jsx,
|
|
108
|
+
* html
|
|
109
|
+
* )
|
|
110
|
+
*/
|
|
111
|
+
declare function build(...configs: Config[]): Promise<void>;
|
|
101
112
|
|
|
102
113
|
/**
|
|
103
114
|
* API pública:
|
package/dist/index.js
CHANGED
|
@@ -77,6 +77,19 @@ function validateDuplicatePrefixes(snippets) {
|
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
+
// src/logger.ts
|
|
81
|
+
var logger = {
|
|
82
|
+
info(message) {
|
|
83
|
+
console.log(`\u2728 EinsteinJS ${message}`);
|
|
84
|
+
},
|
|
85
|
+
success(message) {
|
|
86
|
+
console.log(`\u2705 EinsteinJS ${message}`);
|
|
87
|
+
},
|
|
88
|
+
error(message) {
|
|
89
|
+
console.error(`\u274C EinsteinJS ${message}`);
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
|
|
80
93
|
// node_modules/zod/v4/classic/external.js
|
|
81
94
|
var external_exports = {};
|
|
82
95
|
__export(external_exports, {
|
|
@@ -14603,10 +14616,8 @@ var snippetSchema = external_exports.object({
|
|
|
14603
14616
|
});
|
|
14604
14617
|
|
|
14605
14618
|
// src/build.ts
|
|
14606
|
-
async function
|
|
14607
|
-
const snippets = config2.snippets.map(
|
|
14608
|
-
(snippet) => snippet.build()
|
|
14609
|
-
);
|
|
14619
|
+
async function buildConfig(config2) {
|
|
14620
|
+
const snippets = config2.snippets.map((snippet) => snippet.build());
|
|
14610
14621
|
for (const snippet of snippets) {
|
|
14611
14622
|
snippetSchema.parse(snippet);
|
|
14612
14623
|
}
|
|
@@ -14617,11 +14628,24 @@ async function build(config2) {
|
|
|
14617
14628
|
await mkdir(outputDir, {
|
|
14618
14629
|
recursive: true
|
|
14619
14630
|
});
|
|
14620
|
-
await writeFile(
|
|
14621
|
-
|
|
14622
|
-
|
|
14623
|
-
|
|
14631
|
+
await writeFile(config2.output, JSON.stringify(json2, null, 4), "utf-8");
|
|
14632
|
+
return {
|
|
14633
|
+
output: config2.output,
|
|
14634
|
+
snippets: snippets.length
|
|
14635
|
+
};
|
|
14636
|
+
}
|
|
14637
|
+
async function build(...configs) {
|
|
14638
|
+
const results = await Promise.all(configs.map(buildConfig));
|
|
14639
|
+
const totalSnippets = results.reduce(
|
|
14640
|
+
(acc, result) => acc + result.snippets,
|
|
14641
|
+
0
|
|
14642
|
+
);
|
|
14643
|
+
logger.success(
|
|
14644
|
+
`Generated ${results.length} file(s) from ${totalSnippets} snippet(s).`
|
|
14624
14645
|
);
|
|
14646
|
+
for (const result of results) {
|
|
14647
|
+
logger.info(result.output);
|
|
14648
|
+
}
|
|
14625
14649
|
}
|
|
14626
14650
|
|
|
14627
14651
|
// src/define-config.ts
|