@hiscovega/vundle 0.0.16 → 0.0.17

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/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.0.17](https://github.com/griddo/vundle/compare/v0.0.16...v0.0.17) (2026-01-23)
4
+
5
+
6
+ ### Features
7
+
8
+ * add griddoDeployHashPlugin to include Git commit hash in build output ([d0dbe0e](https://github.com/griddo/vundle/commit/d0dbe0ee57bb19fd199e0fdd7e4036311d3c67fd))
9
+
3
10
  ## [0.0.16](https://github.com/griddo/vundle/compare/v0.0.15...v0.0.16) (2026-01-21)
4
11
 
5
12
  ## [0.0.15](https://github.com/griddo/griddo-bundler/compare/v0.0.14...v0.0.15) (2026-01-21)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hiscovega/vundle",
3
- "version": "0.0.16",
3
+ "version": "0.0.17",
4
4
  "description": "Master bundler configuration for Griddo Instance projects",
5
5
  "main": "vite.config.mjs",
6
6
  "module": "vite.config.mjs",
package/plugins/index.mjs CHANGED
@@ -1,8 +1,72 @@
1
1
  import react from "@vitejs/plugin-react";
2
2
  // import dts from "vite-plugin-dts";
3
3
 
4
+ import { execSync } from "node:child_process";
5
+ import { mkdir, writeFile } from "node:fs/promises";
6
+ import path from "node:path";
4
7
  import { viteStaticCopy } from "vite-plugin-static-copy";
5
8
 
9
+ const griddoDeployHashPlugin = () => {
10
+ /** @type {import("vite").ResolvedConfig | undefined} */
11
+ let resolvedConfig;
12
+
13
+ const getOutputDirs = () => {
14
+ /** @type {string[]} */
15
+ const dirs = [];
16
+
17
+ const output = resolvedConfig?.build?.rollupOptions?.output;
18
+ const outputs = Array.isArray(output) ? output : output ? [output] : [];
19
+
20
+ for (const o of outputs) {
21
+ if (typeof o?.dir === "string" && o.dir) dirs.push(o.dir);
22
+ if (typeof o?.file === "string" && o.file) dirs.push(path.dirname(o.file));
23
+ }
24
+
25
+ if (dirs.length === 0) {
26
+ const outDir = resolvedConfig?.build?.outDir || "dist";
27
+ dirs.push(outDir);
28
+ }
29
+
30
+ return [...new Set(dirs)];
31
+ };
32
+
33
+ const getGitHash = () => {
34
+ try {
35
+ return execSync("git rev-parse HEAD", {
36
+ cwd: resolvedConfig?.root || process.cwd(),
37
+ stdio: ["ignore", "pipe", "ignore"],
38
+ })
39
+ .toString()
40
+ .trim();
41
+ } catch {
42
+ // Fallbacks típicos en CI
43
+ return (
44
+ process.env.GITHUB_SHA || process.env.VERCEL_GIT_COMMIT_SHA || process.env.CF_PAGES_COMMIT_SHA || "unknown"
45
+ );
46
+ }
47
+ };
48
+
49
+ return {
50
+ name: "griddo-deploy-hash",
51
+ apply: "build",
52
+ configResolved(config) {
53
+ resolvedConfig = config;
54
+ },
55
+ async closeBundle() {
56
+ const hash = getGitHash();
57
+ const outputDirs = getOutputDirs();
58
+
59
+ await Promise.all(
60
+ outputDirs.map(async (dir) => {
61
+ const absoluteDir = path.isAbsolute(dir) ? dir : path.join(resolvedConfig?.root || process.cwd(), dir);
62
+ await mkdir(absoluteDir, { recursive: true });
63
+ await writeFile(path.join(absoluteDir, "_griddo-ds-deploy-hash"), `${hash}\n`, "utf8");
64
+ }),
65
+ );
66
+ },
67
+ };
68
+ };
69
+
6
70
  export const plugins = [
7
71
  react(),
8
72
 
@@ -26,4 +90,6 @@ export const plugins = [
26
90
  { src: "thumbnails", dest: "" },
27
91
  ],
28
92
  }),
93
+
94
+ griddoDeployHashPlugin(),
29
95
  ];