@builder.io/dev-tools 1.6.49 → 1.6.50-dev.202505202036.032b583c

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@builder.io/dev-tools",
3
- "version": "1.6.49",
3
+ "version": "1.6.50-dev.202505202036.032b583c",
4
4
  "description": "Builder.io Visual CMS Devtools",
5
5
  "type": "module",
6
6
  "main": "./core/index.cjs",
package/remix/build.cjs CHANGED
@@ -1 +1,132 @@
1
- "use strict";var f=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var w=Object.prototype.hasOwnProperty;var y=(r,e)=>{for(var o in e)f(r,o,{get:e[o],enumerable:!0})},D=(r,e,o,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of S(e))!w.call(r,i)&&i!==o&&f(r,i,{get:()=>e[i],enumerable:!(t=b(e,i))||t.enumerable});return r};var P=r=>D(f({},"__esModule",{value:!0}),r);var T={};y(T,{default:()=>R});module.exports=P(T);var h=require("../core/index.cjs"),p=require("../node/index.cjs"),m=require("../server/index.cjs"),n=require("path"),s=require("fs");var R=(r={})=>e=>{if(r.enabled==null&&(r.enabled=process.env.NODE_ENV!=="production"),r.enabled===!1)return e;let o={...e},t=E(process.cwd()),i=(0,n.dirname)(t);process.env.BUILDER_REMIX_DEVTOOLS_URL="http://localhost:5273/",o.watchPaths=async()=>{let l=await(0,p.createDevToolsNodeSys)({cwd:i}),c=await(0,h.createDevTools)(l),a=await(0,m.createDevToolsServer)({...c,getClientId:()=>"remix-builder-dev-tools",closeAppServer:async()=>{},restartAppServer:async()=>{l.debug("restart server");let d=(0,s.readFileSync)(t,"utf-8");(0,s.writeFileSync)(t,d)},enableAppWatch:async d=>d,...l,...r});return process.env.BUILDER_REMIX_DEVTOOLS_URL=a.getUrl(),typeof e.watchPaths=="function"?e.watchPaths():e.watchPaths?e.watchPaths:[]};let v;v=__dirname;let u=(0,n.join)(v,"server-build","index.mjs");if(!(0,s.existsSync)(u))return console.log(`Builder Devtools unable to run: "${u}" not found`),e;if(typeof e.server=="string"){let l=(0,n.resolve)((0,n.dirname)(t),e.server);if(!(0,s.existsSync)(l))return console.log(`Builder Devtools unable to run: "${l}" set from "${e.server}" server config not found`),e;let c=!1,a=(0,s.readFileSync)(l,"utf-8");for(;a.includes("@remix-run/dev/server-build");)a=a.replace("@remix-run/dev/server-build","@builder.io/dev-tools/remix/server-build"),c=!0;c&&(0,s.writeFileSync)(l,a)}else o.server=u;return o};function E(r){let e=(0,n.resolve)("/");for(let o=0;o<20;o++){let t=(0,n.join)(r,"remix.config.js");if((0,s.existsSync)(t)||(t=(0,n.join)(r,"remix.config.ts"),(0,s.existsSync)(t)))return t;if(r===e)break;r=(0,n.dirname)(r)}throw new Error("Could not find Remix config")}
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // packages/dev-tools/remix/index.ts
21
+ var remix_exports = {};
22
+ __export(remix_exports, {
23
+ default: () => remix_default
24
+ });
25
+ module.exports = __toCommonJS(remix_exports);
26
+ var import_core = require("../core/index.cjs");
27
+ var import_node = require("../node/index.cjs");
28
+ var import_server = require("../server/index.cjs");
29
+ var import_node_path = require("path");
30
+ var import_node_fs = require("fs");
31
+ var remix_default = (devToolsOpts = {}) => {
32
+ return (remixConfig) => {
33
+ if (devToolsOpts.enabled == null) {
34
+ devToolsOpts.enabled = process.env.NODE_ENV !== "production";
35
+ }
36
+ if (devToolsOpts.enabled === false) {
37
+ return remixConfig;
38
+ }
39
+ const withBuilderConfig = { ...remixConfig };
40
+ const configPath = findRemixConfigPath(process.cwd());
41
+ const rootDir = (0, import_node_path.dirname)(configPath);
42
+ process.env.BUILDER_REMIX_DEVTOOLS_URL = `http://localhost:5273/`;
43
+ withBuilderConfig.watchPaths = async () => {
44
+ const sys = await (0, import_node.createDevToolsNodeSys)({
45
+ cwd: rootDir
46
+ });
47
+ const devTools = await (0, import_core.createDevTools)(sys);
48
+ const devToolsServer = await (0, import_server.createDevToolsServer)({
49
+ ...devTools,
50
+ getClientId: () => "remix-builder-dev-tools",
51
+ closeAppServer: async () => {
52
+ },
53
+ restartAppServer: async () => {
54
+ sys.debug("restart server");
55
+ const content = (0, import_node_fs.readFileSync)(configPath, "utf-8");
56
+ (0, import_node_fs.writeFileSync)(configPath, content);
57
+ },
58
+ enableAppWatch: async (enable) => {
59
+ return enable;
60
+ },
61
+ ...sys,
62
+ ...devToolsOpts
63
+ });
64
+ process.env.BUILDER_REMIX_DEVTOOLS_URL = devToolsServer.getUrl();
65
+ if (typeof remixConfig.watchPaths === "function") {
66
+ return remixConfig.watchPaths();
67
+ }
68
+ if (remixConfig.watchPaths) {
69
+ return remixConfig.watchPaths;
70
+ }
71
+ return [];
72
+ };
73
+ let dir;
74
+ if (true) {
75
+ dir = __dirname;
76
+ } else {
77
+ dir = (0, import_node_path.dirname)(fileURLToPath(import_meta.url));
78
+ }
79
+ const devToolServerEntryPath = (0, import_node_path.join)(dir, "server-build", "index.mjs");
80
+ if (!(0, import_node_fs.existsSync)(devToolServerEntryPath)) {
81
+ console.log(
82
+ `Builder Devtools unable to run: "${devToolServerEntryPath}" not found`
83
+ );
84
+ return remixConfig;
85
+ }
86
+ if (typeof remixConfig.server === "string") {
87
+ const userServerEntryPath = (0, import_node_path.resolve)(
88
+ (0, import_node_path.dirname)(configPath),
89
+ remixConfig.server
90
+ );
91
+ if (!(0, import_node_fs.existsSync)(userServerEntryPath)) {
92
+ console.log(
93
+ `Builder Devtools unable to run: "${userServerEntryPath}" set from "${remixConfig.server}" server config not found`
94
+ );
95
+ return remixConfig;
96
+ }
97
+ let madeChanges = false;
98
+ let userServerEntryContent = (0, import_node_fs.readFileSync)(userServerEntryPath, "utf-8");
99
+ while (userServerEntryContent.includes("@remix-run/dev/server-build")) {
100
+ userServerEntryContent = userServerEntryContent.replace(
101
+ `@remix-run/dev/server-build`,
102
+ `@builder.io/dev-tools/remix/server-build`
103
+ );
104
+ madeChanges = true;
105
+ }
106
+ if (madeChanges) {
107
+ (0, import_node_fs.writeFileSync)(userServerEntryPath, userServerEntryContent);
108
+ }
109
+ } else {
110
+ withBuilderConfig.server = devToolServerEntryPath;
111
+ }
112
+ return withBuilderConfig;
113
+ };
114
+ };
115
+ function findRemixConfigPath(dir) {
116
+ const fsRoot = (0, import_node_path.resolve)("/");
117
+ for (let i = 0; i < 20; i++) {
118
+ let configPath = (0, import_node_path.join)(dir, "remix.config.js");
119
+ if ((0, import_node_fs.existsSync)(configPath)) {
120
+ return configPath;
121
+ }
122
+ configPath = (0, import_node_path.join)(dir, "remix.config.ts");
123
+ if ((0, import_node_fs.existsSync)(configPath)) {
124
+ return configPath;
125
+ }
126
+ if (dir === fsRoot) {
127
+ break;
128
+ }
129
+ dir = (0, import_node_path.dirname)(dir);
130
+ }
131
+ throw new Error(`Could not find Remix config`);
132
+ }
package/remix/index.mjs CHANGED
@@ -1,2 +1,114 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{createDevTools as b}from"../core/index.mjs";import{createDevToolsNodeSys as S}from"../node/index.mjs";import{createDevToolsServer as w}from"../server/index.mjs";import{dirname as i,join as d,resolve as h}from"path";import{existsSync as a,readFileSync as f,writeFileSync as p}from"fs";import{fileURLToPath as y}from"url";var L=(r={})=>e=>{if(r.enabled==null&&(r.enabled=process.env.NODE_ENV!=="production"),r.enabled===!1)return e;let n={...e},t=D(process.cwd()),m=i(t);process.env.BUILDER_REMIX_DEVTOOLS_URL="http://localhost:5273/",n.watchPaths=async()=>{let o=await S({cwd:m}),l=await b(o),s=await w({...l,getClientId:()=>"remix-builder-dev-tools",closeAppServer:async()=>{},restartAppServer:async()=>{o.debug("restart server");let u=f(t,"utf-8");p(t,u)},enableAppWatch:async u=>u,...o,...r});return process.env.BUILDER_REMIX_DEVTOOLS_URL=s.getUrl(),typeof e.watchPaths=="function"?e.watchPaths():e.watchPaths?e.watchPaths:[]};let v;v=i(y(import.meta.url));let c=d(v,"server-build","index.mjs");if(!a(c))return console.log(`Builder Devtools unable to run: "${c}" not found`),e;if(typeof e.server=="string"){let o=h(i(t),e.server);if(!a(o))return console.log(`Builder Devtools unable to run: "${o}" set from "${e.server}" server config not found`),e;let l=!1,s=f(o,"utf-8");for(;s.includes("@remix-run/dev/server-build");)s=s.replace("@remix-run/dev/server-build","@builder.io/dev-tools/remix/server-build"),l=!0;l&&p(o,s)}else n.server=c;return n};function D(r){let e=h("/");for(let n=0;n<20;n++){let t=d(r,"remix.config.js");if(a(t)||(t=d(r,"remix.config.ts"),a(t)))return t;if(r===e)break;r=i(r)}throw new Error("Could not find Remix config")}export{L as default};
2
+
3
+ // packages/dev-tools/remix/index.ts
4
+ import { createDevTools } from "../core/index.mjs";
5
+ import { createDevToolsNodeSys } from "../node/index.mjs";
6
+ import { createDevToolsServer } from "../server/index.mjs";
7
+ import { dirname, join, resolve } from "path";
8
+ import { existsSync, readFileSync, writeFileSync } from "fs";
9
+ import { fileURLToPath } from "url";
10
+ var remix_default = (devToolsOpts = {}) => {
11
+ return (remixConfig) => {
12
+ if (devToolsOpts.enabled == null) {
13
+ devToolsOpts.enabled = process.env.NODE_ENV !== "production";
14
+ }
15
+ if (devToolsOpts.enabled === false) {
16
+ return remixConfig;
17
+ }
18
+ const withBuilderConfig = { ...remixConfig };
19
+ const configPath = findRemixConfigPath(process.cwd());
20
+ const rootDir = dirname(configPath);
21
+ process.env.BUILDER_REMIX_DEVTOOLS_URL = `http://localhost:5273/`;
22
+ withBuilderConfig.watchPaths = async () => {
23
+ const sys = await createDevToolsNodeSys({
24
+ cwd: rootDir
25
+ });
26
+ const devTools = await createDevTools(sys);
27
+ const devToolsServer = await createDevToolsServer({
28
+ ...devTools,
29
+ getClientId: () => "remix-builder-dev-tools",
30
+ closeAppServer: async () => {
31
+ },
32
+ restartAppServer: async () => {
33
+ sys.debug("restart server");
34
+ const content = readFileSync(configPath, "utf-8");
35
+ writeFileSync(configPath, content);
36
+ },
37
+ enableAppWatch: async (enable) => {
38
+ return enable;
39
+ },
40
+ ...sys,
41
+ ...devToolsOpts
42
+ });
43
+ process.env.BUILDER_REMIX_DEVTOOLS_URL = devToolsServer.getUrl();
44
+ if (typeof remixConfig.watchPaths === "function") {
45
+ return remixConfig.watchPaths();
46
+ }
47
+ if (remixConfig.watchPaths) {
48
+ return remixConfig.watchPaths;
49
+ }
50
+ return [];
51
+ };
52
+ let dir;
53
+ if (false) {
54
+ dir = __dirname;
55
+ } else {
56
+ dir = dirname(fileURLToPath(import.meta.url));
57
+ }
58
+ const devToolServerEntryPath = join(dir, "server-build", "index.mjs");
59
+ if (!existsSync(devToolServerEntryPath)) {
60
+ console.log(
61
+ `Builder Devtools unable to run: "${devToolServerEntryPath}" not found`
62
+ );
63
+ return remixConfig;
64
+ }
65
+ if (typeof remixConfig.server === "string") {
66
+ const userServerEntryPath = resolve(
67
+ dirname(configPath),
68
+ remixConfig.server
69
+ );
70
+ if (!existsSync(userServerEntryPath)) {
71
+ console.log(
72
+ `Builder Devtools unable to run: "${userServerEntryPath}" set from "${remixConfig.server}" server config not found`
73
+ );
74
+ return remixConfig;
75
+ }
76
+ let madeChanges = false;
77
+ let userServerEntryContent = readFileSync(userServerEntryPath, "utf-8");
78
+ while (userServerEntryContent.includes("@remix-run/dev/server-build")) {
79
+ userServerEntryContent = userServerEntryContent.replace(
80
+ `@remix-run/dev/server-build`,
81
+ `@builder.io/dev-tools/remix/server-build`
82
+ );
83
+ madeChanges = true;
84
+ }
85
+ if (madeChanges) {
86
+ writeFileSync(userServerEntryPath, userServerEntryContent);
87
+ }
88
+ } else {
89
+ withBuilderConfig.server = devToolServerEntryPath;
90
+ }
91
+ return withBuilderConfig;
92
+ };
93
+ };
94
+ function findRemixConfigPath(dir) {
95
+ const fsRoot = resolve("/");
96
+ for (let i = 0; i < 20; i++) {
97
+ let configPath = join(dir, "remix.config.js");
98
+ if (existsSync(configPath)) {
99
+ return configPath;
100
+ }
101
+ configPath = join(dir, "remix.config.ts");
102
+ if (existsSync(configPath)) {
103
+ return configPath;
104
+ }
105
+ if (dir === fsRoot) {
106
+ break;
107
+ }
108
+ dir = dirname(dir);
109
+ }
110
+ throw new Error(`Could not find Remix config`);
111
+ }
112
+ export {
113
+ remix_default as default
114
+ };