@bigbinary/neeto-commons-frontend 4.13.59 → 4.13.60

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,83 @@
1
+ const fs = require("fs");
2
+ const path = require("path");
3
+
4
+ const copy = require("rollup-plugin-copy");
5
+
6
+ const emitReadyFile = destination => ({
7
+ name: "emit-ready-file",
8
+ writeBundle: () => {
9
+ const markerPath = path.join(destination, ".ready");
10
+ // eslint-disable-next-line security/detect-non-literal-fs-filename
11
+ require("fs").writeFileSync(
12
+ markerPath,
13
+ `Built at ${new Date().toISOString()}`
14
+ );
15
+ },
16
+ });
17
+
18
+ const watchTranslations = currentDir => ({
19
+ name: "watch-translations",
20
+ buildStart() {
21
+ const possiblePaths = [
22
+ path.resolve(currentDir, "app/javascript/src/translations"),
23
+ path.resolve(currentDir, "src/translations"),
24
+ ];
25
+
26
+ const translationsPath = possiblePaths.find(fs.existsSync);
27
+
28
+ if (translationsPath) {
29
+ this.addWatchFile(translationsPath);
30
+ }
31
+ },
32
+ });
33
+
34
+ const copyFiles = (destination, customCopyPaths) => {
35
+ const targets = [
36
+ { src: "package.json", dest: destination },
37
+ { src: "*.d.ts", dest: destination },
38
+ { src: "types/", dest: destination },
39
+ { src: "LICENSE.md", dest: destination },
40
+ { src: "src/translations", dest: path.join(destination, "src") },
41
+ {
42
+ src: "app/javascript/src/translations",
43
+ dest: path.join(destination, "app/javascript/src"),
44
+ },
45
+ ...customCopyPaths.map(p => ({
46
+ src: p.src,
47
+ dest: path.join(destination, p.dest),
48
+ })),
49
+ ];
50
+
51
+ const safeTargets = targets.filter(t => {
52
+ try {
53
+ return fs.existsSync(t.src);
54
+ } catch {
55
+ return false;
56
+ }
57
+ });
58
+
59
+ return copy({ targets: safeTargets });
60
+ };
61
+
62
+ const buildWatchConfig = ({ currentDir, args, customCopyPaths = [] }) => {
63
+ if (!args.app) return { watchPlugins: [], appPath: null };
64
+
65
+ const packageJson = require(path.resolve(currentDir, "package.json"));
66
+
67
+ const appPath = path.resolve(
68
+ currentDir,
69
+ args.app,
70
+ "node_modules",
71
+ packageJson.name
72
+ );
73
+
74
+ const plugins = [
75
+ watchTranslations(currentDir),
76
+ copyFiles(appPath, customCopyPaths),
77
+ emitReadyFile(appPath),
78
+ ];
79
+
80
+ return { watchPlugins: plugins, appPath };
81
+ };
82
+
83
+ module.exports = { buildWatchConfig };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bigbinary/neeto-commons-frontend",
3
- "version": "4.13.59",
3
+ "version": "4.13.60",
4
4
  "description": "A package encapsulating common code across neeto projects including initializers, utility functions, common components and hooks and so on.",
5
5
  "repository": "git@github.com:bigbinary/neeto-commons-frontend.git",
6
6
  "author": "Amaljith K <amaljith.k@bigbinary.com>",