builder.io 1.1.28-1 → 1.1.29
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/angular/index.cjs +1 -46
- package/angular/index.mjs +1 -21
- package/cli/index.cjs +1518 -53221
- package/cli/index.cjs.map +4 -4
- package/core/index.cjs +828 -11649
- package/core/index.mjs +828 -11639
- package/figma/index.cjs +1 -35
- package/figma/index.mjs +1 -14
- package/node/index.cjs +3 -355
- package/node/index.mjs +3 -325
- package/package.json +2 -2
- package/remix/build.cjs +1 -132
- package/remix/index.mjs +1 -112
- package/server/index.cjs +223 -900
- package/server/index.mjs +225 -874
- package/vite/index.cjs +3 -142
- package/vite/index.mjs +3 -107
- package/webpack/index.cjs +27 -2875
- package/webpack/index.mjs +27 -2863
package/node/index.mjs
CHANGED
|
@@ -1,325 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
mkdir,
|
|
5
|
-
readdir,
|
|
6
|
-
readFile,
|
|
7
|
-
stat,
|
|
8
|
-
writeFile
|
|
9
|
-
} from "node:fs/promises";
|
|
10
|
-
import { createHash } from "node:crypto";
|
|
11
|
-
import { existsSync, readdirSync, readFileSync, statSync } from "node:fs";
|
|
12
|
-
import { homedir, hostname } from "node:os";
|
|
13
|
-
import path from "node:path";
|
|
14
|
-
import prettier from "prettier";
|
|
15
|
-
import ts from "typescript";
|
|
16
|
-
import launchEditor from "launch-editor";
|
|
17
|
-
|
|
18
|
-
// packages/dev-tools/common/fs.ts
|
|
19
|
-
async function findPackageJson(sys, dir) {
|
|
20
|
-
const fsRoot = sys.resolve("/");
|
|
21
|
-
for (let i = 0; i < 20; i++) {
|
|
22
|
-
const pkgJsonPath = sys.join(dir, "package.json");
|
|
23
|
-
const content = await sys.readFile(pkgJsonPath);
|
|
24
|
-
if (content) {
|
|
25
|
-
const pkgJson = JSON.parse(content);
|
|
26
|
-
return pkgJson;
|
|
27
|
-
}
|
|
28
|
-
if (dir === fsRoot) {
|
|
29
|
-
break;
|
|
30
|
-
}
|
|
31
|
-
dir = sys.dirname(dir);
|
|
32
|
-
}
|
|
33
|
-
return null;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
// packages/dev-tools/core/detect-frameworks.ts
|
|
37
|
-
async function detectFrameworks(sys) {
|
|
38
|
-
const frameworks = [];
|
|
39
|
-
const pkgJson = await findPackageJson(sys, sys.getRootDir());
|
|
40
|
-
if (pkgJson) {
|
|
41
|
-
const depFrameworks = detectFrameworksFromPackageJson(pkgJson);
|
|
42
|
-
frameworks.push(...depFrameworks);
|
|
43
|
-
}
|
|
44
|
-
return frameworks;
|
|
45
|
-
}
|
|
46
|
-
function detectFrameworksFromPackageJson(pkgJson) {
|
|
47
|
-
const frameworks = [];
|
|
48
|
-
if (pkgJson && typeof pkgJson === "object") {
|
|
49
|
-
const depNames = new Set(
|
|
50
|
-
Object.keys({
|
|
51
|
-
...pkgJson.dependencies,
|
|
52
|
-
...pkgJson.devDependencies
|
|
53
|
-
})
|
|
54
|
-
);
|
|
55
|
-
for (const depName of FRAMEWORKS) {
|
|
56
|
-
if (depNames.has(depName)) {
|
|
57
|
-
if (!frameworks.some((f) => f.name === depName)) {
|
|
58
|
-
frameworks.push({ name: depName });
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
return frameworks;
|
|
64
|
-
}
|
|
65
|
-
var FRAMEWORKS = [
|
|
66
|
-
// toolkit frameworks
|
|
67
|
-
"@shopify/remix-oxygen",
|
|
68
|
-
"@shopify/hydrogen",
|
|
69
|
-
// meta frameworks
|
|
70
|
-
"@builder.io/qwik-city",
|
|
71
|
-
"@remix-run/react",
|
|
72
|
-
"@sveltejs/kit",
|
|
73
|
-
"astro",
|
|
74
|
-
"gatsby",
|
|
75
|
-
"next",
|
|
76
|
-
"nuxt",
|
|
77
|
-
// frameworks
|
|
78
|
-
"@builder.io/qwik",
|
|
79
|
-
"@angular/core",
|
|
80
|
-
"react",
|
|
81
|
-
"solid-js",
|
|
82
|
-
"svelte",
|
|
83
|
-
"vue"
|
|
84
|
-
];
|
|
85
|
-
|
|
86
|
-
// packages/dev-tools/node/node-sys.ts
|
|
87
|
-
import { spawnSync } from "node:child_process";
|
|
88
|
-
async function createDevToolsNodeSys(opts) {
|
|
89
|
-
const onChangeCallbacks = /* @__PURE__ */ new Set();
|
|
90
|
-
const debug = (...args) => {
|
|
91
|
-
if (process.env.DEBUG) {
|
|
92
|
-
const d = /* @__PURE__ */ new Date();
|
|
93
|
-
const ts2 = `${String(d.getMinutes()).padStart(2, "0")}:${String(
|
|
94
|
-
d.getSeconds()
|
|
95
|
-
).padStart(2, "0")}.${String(d.getMilliseconds()).padStart(3, "0")}`;
|
|
96
|
-
console.debug(ts2, `[builder-dev-tools]`, ...args);
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
const hash = async (str) => {
|
|
100
|
-
const hash2 = createHash("md5");
|
|
101
|
-
hash2.update(str);
|
|
102
|
-
return hash2.digest("hex");
|
|
103
|
-
};
|
|
104
|
-
const nodeFs = {
|
|
105
|
-
...path,
|
|
106
|
-
getRootDir: () => path.normalize(opts.getRootDir()),
|
|
107
|
-
cwd: () => process.cwd(),
|
|
108
|
-
exists: async (p) => {
|
|
109
|
-
validatePath(opts, p);
|
|
110
|
-
try {
|
|
111
|
-
await access(p);
|
|
112
|
-
return true;
|
|
113
|
-
} catch (e) {
|
|
114
|
-
return false;
|
|
115
|
-
}
|
|
116
|
-
},
|
|
117
|
-
existsSync: (p) => {
|
|
118
|
-
return existsSync(p);
|
|
119
|
-
},
|
|
120
|
-
readdir: async (p, absolutePaths) => {
|
|
121
|
-
validatePath(opts, p);
|
|
122
|
-
const items = await readdir(p);
|
|
123
|
-
if (absolutePaths) {
|
|
124
|
-
return items.map((i) => path.join(p, i));
|
|
125
|
-
}
|
|
126
|
-
return items;
|
|
127
|
-
},
|
|
128
|
-
readdirSync: (p) => {
|
|
129
|
-
validatePath(opts, p);
|
|
130
|
-
return readdirSync(p);
|
|
131
|
-
},
|
|
132
|
-
readFile: async (p) => {
|
|
133
|
-
validatePath(opts, p);
|
|
134
|
-
try {
|
|
135
|
-
const content = await readFile(p, "utf-8");
|
|
136
|
-
return content;
|
|
137
|
-
} catch (e) {
|
|
138
|
-
if (e.code === "ENOENT") {
|
|
139
|
-
return null;
|
|
140
|
-
}
|
|
141
|
-
debug(e, p);
|
|
142
|
-
throw e;
|
|
143
|
-
}
|
|
144
|
-
},
|
|
145
|
-
readFileSync(p) {
|
|
146
|
-
validatePath(opts, p);
|
|
147
|
-
try {
|
|
148
|
-
return readFileSync(p, "utf-8");
|
|
149
|
-
} catch (e) {
|
|
150
|
-
if (e.code === "ENOENT") {
|
|
151
|
-
return null;
|
|
152
|
-
}
|
|
153
|
-
debug(e, p);
|
|
154
|
-
throw e;
|
|
155
|
-
}
|
|
156
|
-
},
|
|
157
|
-
stat: async (p) => {
|
|
158
|
-
validatePath(opts, p);
|
|
159
|
-
const s = await stat(p);
|
|
160
|
-
return s;
|
|
161
|
-
},
|
|
162
|
-
statSync: (p) => {
|
|
163
|
-
validatePath(opts, p);
|
|
164
|
-
return statSync(p);
|
|
165
|
-
},
|
|
166
|
-
writeFile: async (p, contents) => {
|
|
167
|
-
validatePath(opts, p);
|
|
168
|
-
p = path.normalize(p);
|
|
169
|
-
const fileInfo = {
|
|
170
|
-
path: p,
|
|
171
|
-
basename: path.basename(p),
|
|
172
|
-
dirname: path.dirname(p),
|
|
173
|
-
extname: path.extname(p)
|
|
174
|
-
};
|
|
175
|
-
await mkdir(path.dirname(p), { recursive: true });
|
|
176
|
-
await writeFile(p, contents);
|
|
177
|
-
for (const onChangeCallback of onChangeCallbacks) {
|
|
178
|
-
await onChangeCallback(fileInfo);
|
|
179
|
-
}
|
|
180
|
-
},
|
|
181
|
-
hash,
|
|
182
|
-
getDeviceId: () => hash(`${hostname()}:${homedir()}`),
|
|
183
|
-
formatCode: async (filePath, code) => {
|
|
184
|
-
let userOpts = null;
|
|
185
|
-
try {
|
|
186
|
-
userOpts = await prettier.resolveConfig(filePath);
|
|
187
|
-
} catch (e) {
|
|
188
|
-
}
|
|
189
|
-
try {
|
|
190
|
-
return prettier.format(code, {
|
|
191
|
-
...userOpts,
|
|
192
|
-
filepath: filePath
|
|
193
|
-
});
|
|
194
|
-
} catch (e) {
|
|
195
|
-
}
|
|
196
|
-
return code;
|
|
197
|
-
},
|
|
198
|
-
on: (eventName, callback) => {
|
|
199
|
-
if (eventName === "change") {
|
|
200
|
-
onChangeCallbacks.add(callback);
|
|
201
|
-
}
|
|
202
|
-
},
|
|
203
|
-
off: (eventName, callback) => {
|
|
204
|
-
if (eventName === "change") {
|
|
205
|
-
onChangeCallbacks.delete(callback);
|
|
206
|
-
}
|
|
207
|
-
},
|
|
208
|
-
debug,
|
|
209
|
-
launchEditor: async (file) => {
|
|
210
|
-
try {
|
|
211
|
-
let filePath = file.filePath;
|
|
212
|
-
if (typeof file.line === "number") {
|
|
213
|
-
filePath += `:${file.line}`;
|
|
214
|
-
if (typeof file.column === "number") {
|
|
215
|
-
filePath += `:${file.column}`;
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
launchEditor(filePath, "code", (p, e) => {
|
|
219
|
-
console.error(`Failed to launch editor for ${p}`);
|
|
220
|
-
if (e) {
|
|
221
|
-
console.error(e);
|
|
222
|
-
}
|
|
223
|
-
});
|
|
224
|
-
} catch (e) {
|
|
225
|
-
console.error(`Failed to launch editor for ${String(e.message || e)}`);
|
|
226
|
-
}
|
|
227
|
-
},
|
|
228
|
-
platform: () => {
|
|
229
|
-
return { runtime: "node", os: process.platform };
|
|
230
|
-
},
|
|
231
|
-
getRepoInfo: async () => {
|
|
232
|
-
const rootDir = path.normalize(opts.getRootDir());
|
|
233
|
-
return {
|
|
234
|
-
remoteUrl: getGitRemoteURL(rootDir),
|
|
235
|
-
defaultBranch: getGitRepoDefaultBranchName(rootDir),
|
|
236
|
-
commit: getGitCommit(rootDir),
|
|
237
|
-
currentBranch: getCurrentBranchName(rootDir)
|
|
238
|
-
};
|
|
239
|
-
},
|
|
240
|
-
getFrameworks: () => [],
|
|
241
|
-
ts,
|
|
242
|
-
version: true ? "1.1.28-dev" : "0.0.0",
|
|
243
|
-
sdkVersion: null,
|
|
244
|
-
ignoreMissingConfig: opts.ignoreMissingConfig,
|
|
245
|
-
kind: null
|
|
246
|
-
};
|
|
247
|
-
const frameworks = await detectFrameworks(nodeFs);
|
|
248
|
-
nodeFs.getFrameworks = () => frameworks;
|
|
249
|
-
return nodeFs;
|
|
250
|
-
}
|
|
251
|
-
function validatePath(opts, userPath) {
|
|
252
|
-
if (opts.skipValidate) {
|
|
253
|
-
return;
|
|
254
|
-
}
|
|
255
|
-
if (!userPath) {
|
|
256
|
-
throw new Error(`Invalid path: ${userPath} (7340)`);
|
|
257
|
-
}
|
|
258
|
-
userPath = path.normalize(path.resolve(userPath));
|
|
259
|
-
const rootDir = opts.getRootDir();
|
|
260
|
-
if (!userPath.startsWith(rootDir) && !userPath.includes("node_modules")) {
|
|
261
|
-
throw new Error(`Invalid path: ${userPath} (7341)`);
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
function getGitRemoteURL(repoPath) {
|
|
265
|
-
try {
|
|
266
|
-
const spawn = spawnSync("git", ["config", "--get", "remote.origin.url"], {
|
|
267
|
-
cwd: repoPath
|
|
268
|
-
});
|
|
269
|
-
const output = spawn.stdout;
|
|
270
|
-
return (output || "").toString().trim();
|
|
271
|
-
} catch (error) {
|
|
272
|
-
console.error("Error getting git remote URL:", error);
|
|
273
|
-
return "";
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
function getGitRepoDefaultBranchName(repoPath) {
|
|
277
|
-
const DEFAULT_BRANCH_NAME = "master";
|
|
278
|
-
try {
|
|
279
|
-
const gitBranchResult = spawnSync("git", ["branch", "-r"], {
|
|
280
|
-
cwd: repoPath
|
|
281
|
-
});
|
|
282
|
-
if (!gitBranchResult.stdout) {
|
|
283
|
-
return DEFAULT_BRANCH_NAME;
|
|
284
|
-
}
|
|
285
|
-
const branches = gitBranchResult.stdout.toString().trim().split("\n").map((s) => s.trim());
|
|
286
|
-
if (branches.includes("origin/main")) {
|
|
287
|
-
return "main";
|
|
288
|
-
} else {
|
|
289
|
-
return DEFAULT_BRANCH_NAME;
|
|
290
|
-
}
|
|
291
|
-
} catch (error) {
|
|
292
|
-
console.error(
|
|
293
|
-
"Error getting git default branch name:",
|
|
294
|
-
error.toString().split("\n")[0]
|
|
295
|
-
);
|
|
296
|
-
return DEFAULT_BRANCH_NAME;
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
function getGitCommit(repoPath) {
|
|
300
|
-
try {
|
|
301
|
-
const spawn = spawnSync("git", ["rev-parse", "HEAD"], {
|
|
302
|
-
cwd: repoPath
|
|
303
|
-
});
|
|
304
|
-
const output = spawn.stdout;
|
|
305
|
-
return (output || "").toString().trim();
|
|
306
|
-
} catch (error) {
|
|
307
|
-
console.error("Error getting git commit:", error);
|
|
308
|
-
return "";
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
function getCurrentBranchName(repoPath) {
|
|
312
|
-
try {
|
|
313
|
-
const spawn = spawnSync("git", ["branch", "--show-current"], {
|
|
314
|
-
cwd: repoPath
|
|
315
|
-
});
|
|
316
|
-
const output = spawn.stdout;
|
|
317
|
-
return (output || "").toString().trim();
|
|
318
|
-
} catch (error) {
|
|
319
|
-
console.error("Error getting current branch name:", error);
|
|
320
|
-
return "";
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
export {
|
|
324
|
-
createDevToolsNodeSys
|
|
325
|
-
};
|
|
1
|
+
import{access as w,mkdir as S,readdir as k,readFile as D,stat as v,writeFile as b}from"node:fs/promises";import{createHash as F}from"node:crypto";import{existsSync as O,readdirSync as C,readFileSync as E,statSync as N}from"node:fs";import{homedir as x,hostname as R}from"node:os";import s from"node:path";import p from"prettier";import T from"typescript";import j from"launch-editor";async function d(r,e){let o=r.resolve("/");for(let i=0;i<20;i++){let c=r.join(e,"package.json"),f=await r.readFile(c);if(f)return JSON.parse(f);if(e===o)break;e=r.dirname(e)}return null}async function m(r){let e=[],o=await d(r,r.getRootDir());if(o){let i=y(o);e.push(...i)}return e}function y(r){let e=[];if(r&&typeof r=="object"){let o=new Set(Object.keys({...r.dependencies,...r.devDependencies}));for(let i of h)o.has(i)&&(e.some(c=>c.name===i)||e.push({name:i}))}return e}var h=["@shopify/remix-oxygen","@shopify/hydrogen","@builder.io/qwik-city","@remix-run/react","@sveltejs/kit","astro","gatsby","next","nuxt","@builder.io/qwik","@angular/core","react","solid-js","svelte","vue"];import{spawnSync as g}from"node:child_process";async function P(r){let e=new Set,o=(...t)=>{if(process.env.DEBUG){let n=new Date,a=`${String(n.getMinutes()).padStart(2,"0")}:${String(n.getSeconds()).padStart(2,"0")}.${String(n.getMilliseconds()).padStart(3,"0")}`;console.debug(a,"[builder-dev-tools]",...t)}},i=async t=>{let n=F("md5");return n.update(t),n.digest("hex")},c={...s,getRootDir:()=>s.normalize(r.getRootDir()),cwd:()=>process.cwd(),exists:async t=>{u(r,t);try{return await w(t),!0}catch{return!1}},existsSync:t=>O(t),readdir:async(t,n)=>{u(r,t);let a=await k(t);return n?a.map(l=>s.join(t,l)):a},readdirSync:t=>(u(r,t),C(t)),readFile:async t=>{u(r,t);try{return await D(t,"utf-8")}catch(n){if(n.code==="ENOENT")return null;throw o(n,t),n}},readFileSync(t){u(r,t);try{return E(t,"utf-8")}catch(n){if(n.code==="ENOENT")return null;throw o(n,t),n}},stat:async t=>(u(r,t),await v(t)),statSync:t=>(u(r,t),N(t)),writeFile:async(t,n)=>{u(r,t),t=s.normalize(t);let a={path:t,basename:s.basename(t),dirname:s.dirname(t),extname:s.extname(t)};await S(s.dirname(t),{recursive:!0}),await b(t,n);for(let l of e)await l(a)},hash:i,getDeviceId:()=>i(`${R()}:${x()}`),formatCode:async(t,n)=>{let a=null;try{a=await p.resolveConfig(t)}catch{}try{return p.format(n,{...a,filepath:t})}catch{}return n},on:(t,n)=>{t==="change"&&e.add(n)},off:(t,n)=>{t==="change"&&e.delete(n)},debug:o,launchEditor:async t=>{try{let n=t.filePath;typeof t.line=="number"&&(n+=`:${t.line}`,typeof t.column=="number"&&(n+=`:${t.column}`)),j(n,"code",(a,l)=>{console.error(`Failed to launch editor for ${a}`),l&&console.error(l)})}catch(n){console.error(`Failed to launch editor for ${String(n.message||n)}`)}},platform:()=>({runtime:"node",os:process.platform}),getRepoInfo:async()=>{let t=s.normalize(r.getRootDir());return{remoteUrl:_(t),defaultBranch:J(t),commit:$(t),currentBranch:I(t)}},getFrameworks:()=>[],ts:T,version:"1.1.29",sdkVersion:null,ignoreMissingConfig:r.ignoreMissingConfig,kind:null},f=await m(c);return c.getFrameworks=()=>f,c}function u(r,e){if(r.skipValidate)return;if(!e)throw new Error(`Invalid path: ${e} (7340)`);e=s.normalize(s.resolve(e));let o=r.getRootDir();if(!e.startsWith(o)&&!e.includes("node_modules"))throw new Error(`Invalid path: ${e} (7341)`)}function _(r){try{return(g("git",["config","--get","remote.origin.url"],{cwd:r}).stdout||"").toString().trim()}catch(e){return console.error("Error getting git remote URL:",e),""}}function J(r){let e="master";try{let o=g("git",["branch","-r"],{cwd:r});return o.stdout&&o.stdout.toString().trim().split(`
|
|
2
|
+
`).map(c=>c.trim()).includes("origin/main")?"main":e}catch(o){return console.error("Error getting git default branch name:",o.toString().split(`
|
|
3
|
+
`)[0]),e}}function $(r){try{return(g("git",["rev-parse","HEAD"],{cwd:r}).stdout||"").toString().trim()}catch(e){return console.error("Error getting git commit:",e),""}}function I(r){try{return(g("git",["branch","--show-current"],{cwd:r}).stdout||"").toString().trim()}catch(e){return console.error("Error getting current branch name:",e),""}}export{P as createDevToolsNodeSys};
|
package/package.json
CHANGED
package/remix/build.cjs
CHANGED
|
@@ -1,132 +1 @@
|
|
|
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("node:path");
|
|
30
|
-
var import_node_fs = require("node: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
|
-
getRootDir: () => 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
|
-
}
|
|
1
|
+
"use strict";var f=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var w=(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))!y.call(r,i)&&i!==o&&f(r,i,{get:()=>e[i],enumerable:!(t=b(e,i))||t.enumerable});return r};var R=r=>D(f({},"__esModule",{value:!0}),r);var T={};w(T,{default:()=>P});module.exports=R(T);var h=require("../core/index.cjs"),p=require("../node/index.cjs"),m=require("../server/index.cjs"),n=require("node:path"),s=require("node:fs");var P=(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)({getRootDir:()=>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")}
|
package/remix/index.mjs
CHANGED
|
@@ -1,112 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { createDevTools } from "../core/index.mjs";
|
|
3
|
-
import { createDevToolsNodeSys } from "../node/index.mjs";
|
|
4
|
-
import { createDevToolsServer } from "../server/index.mjs";
|
|
5
|
-
import { dirname, join, resolve } from "node:path";
|
|
6
|
-
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
7
|
-
import { fileURLToPath } from "node:url";
|
|
8
|
-
var remix_default = (devToolsOpts = {}) => {
|
|
9
|
-
return (remixConfig) => {
|
|
10
|
-
if (devToolsOpts.enabled == null) {
|
|
11
|
-
devToolsOpts.enabled = process.env.NODE_ENV !== "production";
|
|
12
|
-
}
|
|
13
|
-
if (devToolsOpts.enabled === false) {
|
|
14
|
-
return remixConfig;
|
|
15
|
-
}
|
|
16
|
-
const withBuilderConfig = { ...remixConfig };
|
|
17
|
-
const configPath = findRemixConfigPath(process.cwd());
|
|
18
|
-
const rootDir = dirname(configPath);
|
|
19
|
-
process.env.BUILDER_REMIX_DEVTOOLS_URL = `http://localhost:5273/`;
|
|
20
|
-
withBuilderConfig.watchPaths = async () => {
|
|
21
|
-
const sys = await createDevToolsNodeSys({
|
|
22
|
-
getRootDir: () => rootDir
|
|
23
|
-
});
|
|
24
|
-
const devTools = await createDevTools(sys);
|
|
25
|
-
const devToolsServer = await createDevToolsServer({
|
|
26
|
-
...devTools,
|
|
27
|
-
getClientId: () => "remix-builder-dev-tools",
|
|
28
|
-
closeAppServer: async () => {
|
|
29
|
-
},
|
|
30
|
-
restartAppServer: async () => {
|
|
31
|
-
sys.debug("restart server");
|
|
32
|
-
const content = readFileSync(configPath, "utf-8");
|
|
33
|
-
writeFileSync(configPath, content);
|
|
34
|
-
},
|
|
35
|
-
enableAppWatch: async (enable) => {
|
|
36
|
-
return enable;
|
|
37
|
-
},
|
|
38
|
-
...sys,
|
|
39
|
-
...devToolsOpts
|
|
40
|
-
});
|
|
41
|
-
process.env.BUILDER_REMIX_DEVTOOLS_URL = devToolsServer.getUrl();
|
|
42
|
-
if (typeof remixConfig.watchPaths === "function") {
|
|
43
|
-
return remixConfig.watchPaths();
|
|
44
|
-
}
|
|
45
|
-
if (remixConfig.watchPaths) {
|
|
46
|
-
return remixConfig.watchPaths;
|
|
47
|
-
}
|
|
48
|
-
return [];
|
|
49
|
-
};
|
|
50
|
-
let dir;
|
|
51
|
-
if (false) {
|
|
52
|
-
dir = __dirname;
|
|
53
|
-
} else {
|
|
54
|
-
dir = dirname(fileURLToPath(import.meta.url));
|
|
55
|
-
}
|
|
56
|
-
const devToolServerEntryPath = join(dir, "server-build", "index.mjs");
|
|
57
|
-
if (!existsSync(devToolServerEntryPath)) {
|
|
58
|
-
console.log(
|
|
59
|
-
`Builder Devtools unable to run: "${devToolServerEntryPath}" not found`
|
|
60
|
-
);
|
|
61
|
-
return remixConfig;
|
|
62
|
-
}
|
|
63
|
-
if (typeof remixConfig.server === "string") {
|
|
64
|
-
const userServerEntryPath = resolve(
|
|
65
|
-
dirname(configPath),
|
|
66
|
-
remixConfig.server
|
|
67
|
-
);
|
|
68
|
-
if (!existsSync(userServerEntryPath)) {
|
|
69
|
-
console.log(
|
|
70
|
-
`Builder Devtools unable to run: "${userServerEntryPath}" set from "${remixConfig.server}" server config not found`
|
|
71
|
-
);
|
|
72
|
-
return remixConfig;
|
|
73
|
-
}
|
|
74
|
-
let madeChanges = false;
|
|
75
|
-
let userServerEntryContent = readFileSync(userServerEntryPath, "utf-8");
|
|
76
|
-
while (userServerEntryContent.includes("@remix-run/dev/server-build")) {
|
|
77
|
-
userServerEntryContent = userServerEntryContent.replace(
|
|
78
|
-
`@remix-run/dev/server-build`,
|
|
79
|
-
`@builder.io/dev-tools/remix/server-build`
|
|
80
|
-
);
|
|
81
|
-
madeChanges = true;
|
|
82
|
-
}
|
|
83
|
-
if (madeChanges) {
|
|
84
|
-
writeFileSync(userServerEntryPath, userServerEntryContent);
|
|
85
|
-
}
|
|
86
|
-
} else {
|
|
87
|
-
withBuilderConfig.server = devToolServerEntryPath;
|
|
88
|
-
}
|
|
89
|
-
return withBuilderConfig;
|
|
90
|
-
};
|
|
91
|
-
};
|
|
92
|
-
function findRemixConfigPath(dir) {
|
|
93
|
-
const fsRoot = resolve("/");
|
|
94
|
-
for (let i = 0; i < 20; i++) {
|
|
95
|
-
let configPath = join(dir, "remix.config.js");
|
|
96
|
-
if (existsSync(configPath)) {
|
|
97
|
-
return configPath;
|
|
98
|
-
}
|
|
99
|
-
configPath = join(dir, "remix.config.ts");
|
|
100
|
-
if (existsSync(configPath)) {
|
|
101
|
-
return configPath;
|
|
102
|
-
}
|
|
103
|
-
if (dir === fsRoot) {
|
|
104
|
-
break;
|
|
105
|
-
}
|
|
106
|
-
dir = dirname(dir);
|
|
107
|
-
}
|
|
108
|
-
throw new Error(`Could not find Remix config`);
|
|
109
|
-
}
|
|
110
|
-
export {
|
|
111
|
-
remix_default as default
|
|
112
|
-
};
|
|
1
|
+
import{createDevTools as b}from"../core/index.mjs";import{createDevToolsNodeSys as S}from"../node/index.mjs";import{createDevToolsServer as y}from"../server/index.mjs";import{dirname as i,join as d,resolve as h}from"node:path";import{existsSync as a,readFileSync as f,writeFileSync as p}from"node:fs";import{fileURLToPath as w}from"node:url";var B=(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({getRootDir:()=>m}),l=await b(o),s=await y({...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(w(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{B as default};
|