monoverse 0.0.8 → 0.0.10
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/LICENCE +1 -0
- package/README.md +18 -0
- package/dist/assets/index-DIUWvkwu.css +1 -0
- package/dist/assets/index-UQPMV9jG.js +161 -0
- package/dist/assets/index.lazy-B2wDxrXt.js +21 -0
- package/dist/cli.js +481 -0
- package/dist/index.html +14 -0
- package/dist/vite.svg +1 -0
- package/package.json +90 -57
- package/Readme.md +0 -7
- package/build/index.js +0 -65727
- package/build/metafile.js.json +0 -1
- package/build/metafile.server.json +0 -1
- package/cli.js +0 -22
- package/public/android-chrome-192x192.png +0 -0
- package/public/android-chrome-512x512.png +0 -0
- package/public/apple-touch-icon.png +0 -0
- package/public/build/_assets/app-PR3B5ESH.css +0 -1
- package/public/build/_shared/chunk-7QPZBUTN.js +0 -249
- package/public/build/_shared/chunk-G2LHOEOK.js +0 -32
- package/public/build/_shared/chunk-G5WX4PPA.js +0 -1
- package/public/build/_shared/chunk-GWUFOIPA.js +0 -1
- package/public/build/entry.client-7KM2QASU.js +0 -1
- package/public/build/manifest-1941C2DD.js +0 -1
- package/public/build/root-ELHOT54E.js +0 -1
- package/public/build/routes/_index-CPWYYDDU.js +0 -125
- package/public/build/routes/api-H3ZMS4LW.js +0 -1
- package/public/favicon-16x16.png +0 -0
- package/public/favicon-32x32.png +0 -0
- package/public/favicon.ico +0 -0
- package/public/fonts/roboto-flex-v9-latin-regular.woff2 +0 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import{c,r as n,j as e,a as f,$ as g,_ as j,b as v,d as b,u as p,e as k,L as N,B as i,E as x,D as w,f as M,g as P,h as D,i as $,k as R}from"./index-UQPMV9jG.js";/**
|
|
2
|
+
* @license lucide-react v0.363.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const z=c("CirclePlus",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]]);/**
|
|
7
|
+
* @license lucide-react v0.363.0 - ISC
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the ISC license.
|
|
10
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
+
*/const C=c("File",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}]]);/**
|
|
12
|
+
* @license lucide-react v0.363.0 - ISC
|
|
13
|
+
*
|
|
14
|
+
* This source code is licensed under the ISC license.
|
|
15
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
+
*/const E=c("Link",[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]]);/**
|
|
17
|
+
* @license lucide-react v0.363.0 - ISC
|
|
18
|
+
*
|
|
19
|
+
* This source code is licensed under the ISC license.
|
|
20
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
+
*/const _=c("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]),h=n.forwardRef(({className:t,type:s,...a},l)=>e.jsx("input",{type:s,className:f("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t),ref:l,...a}));h.displayName="Input";const L=n.forwardRef((t,s)=>n.createElement(g.label,j({},t,{ref:s,onMouseDown:a=>{var l;(l=t.onMouseDown)===null||l===void 0||l.call(t,a),!a.defaultPrevented&&a.detail>1&&a.preventDefault()}}))),m=L,V=v("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),y=n.forwardRef(({className:t,...s},a)=>e.jsx(m,{ref:a,className:f(V(),t),...s}));y.displayName=m.displayName;const q=b("/_layout/")({component:F});function F(){const{projects:t,removeProject:s,selectProject:a}=p(),[l,o]=n.useState(!1),d=k();return e.jsxs("div",{className:"mt-10",children:[e.jsx("div",{className:"text-center",children:e.jsx(N,{className:"cursor-default"})}),e.jsx("div",{className:"mx-auto mt-10 max-w-xl",children:e.jsxs("div",{className:"flex flex-col items-stretch gap-4",children:[e.jsxs(i,{variant:"link",className:"flex items-center justify-center gap-2",onClick:()=>{o(!0)},children:[e.jsx(z,{}),"Add project"]}),x.PROJECT_MODE==="online",t.list.length>0?t.list.map((r,u)=>e.jsxs("div",{className:"group flex items-center gap-3",children:[e.jsxs(i,{disabled:x.PROJECT_MODE==="online",onClick:()=>{a(r),d.navigate({to:"/overview"})},variant:"ghost",className:"flex grow items-center justify-start gap-2 text-center",children:[r.type==="filepath"?e.jsx(C,{}):e.jsx(E,{}),r.value]}),e.jsx(i,{className:"opacity-30 transition-opacity group-hover:opacity-100",variant:"ghost",onClick:()=>{s(r)},children:e.jsx(_,{})})]},u)):e.jsx("div",{className:"text-center text-2xl font-bold text-[gray] dark:text-muted",children:"No projects added yet."})]})}),l&&e.jsx(O,{open:l,onOpenChange:o})]})}function O({open:t,onOpenChange:s}){const[a,l]=n.useState(""),{type:o}=n.useMemo(()=>{const r=new RegExp("^(https?:\\/\\/)?((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.?)+[a-z]{2,}|((\\d{1,3}\\.){3}\\d{1,3}))(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*(\\?[;&a-z\\d%_.~+=-]*)?(\\#[-a-z\\d_]*)?$","i"),u=/^(\/|([a-zA-Z]:\\)).*$/;return r.test(a)?{type:"url"}:u.test(a)?{type:"filepath"}:{type:"invalid"}},[a]),{addProject:d}=p();return e.jsxs(w,{open:t,onOpenChange:s,children:[e.jsx(M,{className:"bg-background/80"}),e.jsxs(P,{children:[e.jsx(D,{children:"Add Project"}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(y,{htmlFor:"name",children:"Directory Path | Github URL"}),e.jsx(h,{id:"name",value:a,onChange:r=>{l(r.target.value)}})]}),e.jsx($,{children:e.jsx(i,{disabled:o==="invalid",onClick:()=>{R(o!=="invalid"),d({type:o,value:a}),s(!1)},children:"Save changes"})})]})]})}export{q as Route};
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,481 @@
|
|
|
1
|
+
// cli.ts
|
|
2
|
+
import * as trpcExpress from "@trpc/server/adapters/express";
|
|
3
|
+
import express from "express";
|
|
4
|
+
import { fileURLToPath } from "url";
|
|
5
|
+
import path4 from "path";
|
|
6
|
+
|
|
7
|
+
// trpc/server.ts
|
|
8
|
+
import { z as z5 } from "zod";
|
|
9
|
+
|
|
10
|
+
// domain/core/schema/schema.ts
|
|
11
|
+
import { z } from "zod";
|
|
12
|
+
var dependencySchema = z.object({
|
|
13
|
+
name: z.string(),
|
|
14
|
+
versionRange: z.string(),
|
|
15
|
+
type: z.enum([
|
|
16
|
+
"dependency",
|
|
17
|
+
"devDependency",
|
|
18
|
+
"peerDependency",
|
|
19
|
+
"optionalDependency"
|
|
20
|
+
])
|
|
21
|
+
});
|
|
22
|
+
var workspaceSchema = z.object({
|
|
23
|
+
name: z.string(),
|
|
24
|
+
description: z.string().optional(),
|
|
25
|
+
dependencies: z.array(dependencySchema)
|
|
26
|
+
});
|
|
27
|
+
var monorepoSchema = z.object({
|
|
28
|
+
workspaces: z.array(workspaceSchema)
|
|
29
|
+
});
|
|
30
|
+
var dependencyRecordSchema = z.record(z.string());
|
|
31
|
+
var packageJsonSchema = z.object({
|
|
32
|
+
name: z.string(),
|
|
33
|
+
description: z.string().optional(),
|
|
34
|
+
version: z.string().optional(),
|
|
35
|
+
// Dependencies
|
|
36
|
+
dependencies: dependencyRecordSchema.optional(),
|
|
37
|
+
devDependencies: dependencyRecordSchema.optional(),
|
|
38
|
+
peerDependencies: dependencyRecordSchema.optional(),
|
|
39
|
+
optionalDependencies: dependencyRecordSchema.optional()
|
|
40
|
+
}).passthrough();
|
|
41
|
+
|
|
42
|
+
// domain/tools/ts.ts
|
|
43
|
+
var removeUndefined = (obj) => {
|
|
44
|
+
const result = { ...obj };
|
|
45
|
+
for (const key in result) {
|
|
46
|
+
const value = result[key];
|
|
47
|
+
if (value === void 0) {
|
|
48
|
+
delete result[key];
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return result;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
// domain/core/schema/transform.ts
|
|
55
|
+
var transformPackageJsonToWorkspace = (packageJson) => {
|
|
56
|
+
const validatedPackageJson = packageJsonSchema.parse(packageJson);
|
|
57
|
+
const {
|
|
58
|
+
dependencies,
|
|
59
|
+
devDependencies,
|
|
60
|
+
peerDependencies,
|
|
61
|
+
optionalDependencies
|
|
62
|
+
} = validatedPackageJson;
|
|
63
|
+
const getDependencies = (list, type) => {
|
|
64
|
+
if (!list)
|
|
65
|
+
return [];
|
|
66
|
+
return Object.entries(list).map(([name, versionRange]) => {
|
|
67
|
+
return {
|
|
68
|
+
name,
|
|
69
|
+
versionRange,
|
|
70
|
+
type
|
|
71
|
+
};
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
return workspaceSchema.parse(
|
|
75
|
+
// removeUndefined to ensure that the workspace doesn't have any undefined
|
|
76
|
+
removeUndefined({
|
|
77
|
+
name: validatedPackageJson.name,
|
|
78
|
+
description: validatedPackageJson.description,
|
|
79
|
+
dependencies: [
|
|
80
|
+
...getDependencies(dependencies, "dependency"),
|
|
81
|
+
...getDependencies(devDependencies, "devDependency"),
|
|
82
|
+
...getDependencies(peerDependencies, "peerDependency"),
|
|
83
|
+
...getDependencies(optionalDependencies, "optionalDependency")
|
|
84
|
+
]
|
|
85
|
+
})
|
|
86
|
+
);
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
// domain/core/version.ts
|
|
90
|
+
import { gt, maxSatisfying, minSatisfying } from "semver";
|
|
91
|
+
|
|
92
|
+
// domain/implementation/api/bundlephobia.ts
|
|
93
|
+
import { z as z2 } from "zod";
|
|
94
|
+
var requestSchema = z2.string();
|
|
95
|
+
var responseSchema = z2.object({
|
|
96
|
+
assets: z2.array(
|
|
97
|
+
z2.object({
|
|
98
|
+
gzip: z2.number(),
|
|
99
|
+
name: z2.string(),
|
|
100
|
+
size: z2.number(),
|
|
101
|
+
type: z2.string()
|
|
102
|
+
})
|
|
103
|
+
),
|
|
104
|
+
dependencyCount: z2.number(),
|
|
105
|
+
dependencySizes: z2.array(
|
|
106
|
+
z2.object({ approximateSize: z2.number(), name: z2.string() })
|
|
107
|
+
),
|
|
108
|
+
description: z2.string().optional(),
|
|
109
|
+
name: z2.string(),
|
|
110
|
+
version: z2.string()
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
// domain/implementation/api/package-info.ts
|
|
114
|
+
import { z as z4 } from "zod";
|
|
115
|
+
|
|
116
|
+
// domain/implementation/api/schema.ts
|
|
117
|
+
import { z as z3 } from "zod";
|
|
118
|
+
var packageSchema = z3.object({
|
|
119
|
+
name: z3.string(),
|
|
120
|
+
description: z3.string().optional(),
|
|
121
|
+
repository: z3.string().optional(),
|
|
122
|
+
licence: z3.string().optional(),
|
|
123
|
+
versions: z3.array(z3.string())
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
// domain/implementation/api/package-info.ts
|
|
127
|
+
var requestSchema2 = z4.string();
|
|
128
|
+
var responseSchema2 = z4.object({
|
|
129
|
+
name: z4.string(),
|
|
130
|
+
versions: z4.record(z4.any()),
|
|
131
|
+
description: z4.string().optional(),
|
|
132
|
+
repository: z4.object({
|
|
133
|
+
url: z4.string().optional()
|
|
134
|
+
}).optional(),
|
|
135
|
+
licence: z4.string().optional()
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
// domain/implementation/filesystem/filesystem.ts
|
|
139
|
+
import { getPackages as getWorkspaces } from "@monorepo-utils/package-utils";
|
|
140
|
+
import fs from "fs";
|
|
141
|
+
import path from "path";
|
|
142
|
+
import invariant from "tiny-invariant";
|
|
143
|
+
var getMonorepoInfo = (dirPath) => {
|
|
144
|
+
const monorepoDir = detectMonorepoDir(dirPath);
|
|
145
|
+
const workspaceDir = detectWorkspaceDir(dirPath);
|
|
146
|
+
if (monorepoDir) {
|
|
147
|
+
const workspaces = getMonorepoWorkspacesAtDir(monorepoDir);
|
|
148
|
+
invariant(workspaces !== void 0, "monorepo should be defined");
|
|
149
|
+
return {
|
|
150
|
+
workspaces
|
|
151
|
+
};
|
|
152
|
+
} else if (workspaceDir) {
|
|
153
|
+
const workspace = getWorkspaceAtDir(workspaceDir);
|
|
154
|
+
invariant(workspace !== void 0, "workspace should be defined");
|
|
155
|
+
return {
|
|
156
|
+
workspaces: [workspace]
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
return void 0;
|
|
160
|
+
};
|
|
161
|
+
var detectMonorepoDir = (dirPath) => {
|
|
162
|
+
dirPath = path.resolve(dirPath);
|
|
163
|
+
while (true) {
|
|
164
|
+
const monorepo = getMonorepoWorkspacesAtDir(dirPath);
|
|
165
|
+
if (monorepo)
|
|
166
|
+
return dirPath;
|
|
167
|
+
const parentDir = path.dirname(dirPath);
|
|
168
|
+
if (parentDir === dirPath)
|
|
169
|
+
return void 0;
|
|
170
|
+
dirPath = parentDir;
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
function getMonorepoWorkspacesAtDir(dir) {
|
|
174
|
+
const workspaces = getWorkspaces(dir);
|
|
175
|
+
if (!workspaces || workspaces.length === 0)
|
|
176
|
+
return void 0;
|
|
177
|
+
return workspaces.map((workspace) => {
|
|
178
|
+
const { packageJSON, location } = workspace;
|
|
179
|
+
const parsedPackageJson = packageJsonSchema.parse(packageJSON);
|
|
180
|
+
return {
|
|
181
|
+
workspace: transformPackageJsonToWorkspace(packageJSON),
|
|
182
|
+
location,
|
|
183
|
+
packageJSON: parsedPackageJson
|
|
184
|
+
};
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
function detectWorkspaceDir(dirPath) {
|
|
188
|
+
while (true) {
|
|
189
|
+
const workspace = getWorkspaceAtDir(dirPath);
|
|
190
|
+
if (workspace)
|
|
191
|
+
return dirPath;
|
|
192
|
+
const parentDir = path.dirname(dirPath);
|
|
193
|
+
if (parentDir === dirPath)
|
|
194
|
+
return void 0;
|
|
195
|
+
dirPath = parentDir;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
function getWorkspaceAtDir(dir) {
|
|
199
|
+
const workspacePackageJson = path.resolve(dir, "package.json");
|
|
200
|
+
try {
|
|
201
|
+
const packageJson = JSON.parse(
|
|
202
|
+
fs.readFileSync(workspacePackageJson, "utf-8")
|
|
203
|
+
);
|
|
204
|
+
const parsedPackageJson = packageJsonSchema.parse(packageJson);
|
|
205
|
+
return {
|
|
206
|
+
location: dir,
|
|
207
|
+
packageJSON: parsedPackageJson,
|
|
208
|
+
workspace: transformPackageJsonToWorkspace(packageJson)
|
|
209
|
+
};
|
|
210
|
+
} catch {
|
|
211
|
+
return void 0;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// domain/implementation/filesystem/sync-dependency-versions.ts
|
|
216
|
+
import fs2 from "fs";
|
|
217
|
+
import path2 from "path";
|
|
218
|
+
import { sortPackageJson } from "sort-package-json";
|
|
219
|
+
var syncDependencyVersions = (monorepoInfo, updates) => {
|
|
220
|
+
try {
|
|
221
|
+
const updatedWorkspaces = /* @__PURE__ */ new Set();
|
|
222
|
+
for (const update of updates) {
|
|
223
|
+
for (const { packageJSON, workspace } of monorepoInfo.workspaces) {
|
|
224
|
+
if (packageJSON.dependencies?.[update.dependencyName]) {
|
|
225
|
+
packageJSON.dependencies[update.dependencyName] = update.versionRange;
|
|
226
|
+
updatedWorkspaces.add(workspace.name);
|
|
227
|
+
}
|
|
228
|
+
if (packageJSON.devDependencies?.[update.dependencyName]) {
|
|
229
|
+
packageJSON.devDependencies[update.dependencyName] = update.versionRange;
|
|
230
|
+
updatedWorkspaces.add(workspace.name);
|
|
231
|
+
}
|
|
232
|
+
if (packageJSON.peerDependencies?.[update.dependencyName]) {
|
|
233
|
+
packageJSON.peerDependencies[update.dependencyName] = update.versionRange;
|
|
234
|
+
updatedWorkspaces.add(workspace.name);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
for (const {
|
|
239
|
+
location,
|
|
240
|
+
workspace,
|
|
241
|
+
packageJSON
|
|
242
|
+
} of monorepoInfo.workspaces) {
|
|
243
|
+
if (updatedWorkspaces.has(workspace.name)) {
|
|
244
|
+
fs2.writeFileSync(
|
|
245
|
+
path2.join(location, "package.json"),
|
|
246
|
+
sortPackageJson(JSON.stringify(packageJSON, null, 2))
|
|
247
|
+
);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
} catch {
|
|
251
|
+
return { success: false };
|
|
252
|
+
}
|
|
253
|
+
return { success: true };
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
// domain/implementation/git/clone.ts
|
|
257
|
+
import AdmZip from "adm-zip";
|
|
258
|
+
import fs3, { createWriteStream } from "fs";
|
|
259
|
+
import { mkdtemp, rm } from "fs/promises";
|
|
260
|
+
import os from "os";
|
|
261
|
+
import path3 from "path";
|
|
262
|
+
import { Readable } from "stream";
|
|
263
|
+
import { pipeline } from "stream/promises";
|
|
264
|
+
var downloadGitRepo = async (url) => {
|
|
265
|
+
const tempDir = await mkdtemp(path3.join(os.tmpdir(), "monoverse-"));
|
|
266
|
+
const outputPath = path3.join(tempDir, "github-zip.zip");
|
|
267
|
+
const outputDir = path3.join(tempDir, "github-extract");
|
|
268
|
+
await rm(outputDir, { recursive: true, force: true });
|
|
269
|
+
await rm(outputPath, { force: true });
|
|
270
|
+
const { ok } = await downloadZip(url, outputPath);
|
|
271
|
+
if (!ok) {
|
|
272
|
+
throw new Error("Failed to download the zip file");
|
|
273
|
+
}
|
|
274
|
+
const zip = new AdmZip(outputPath);
|
|
275
|
+
zip.extractAllTo(outputDir, true);
|
|
276
|
+
return {
|
|
277
|
+
projectDir: await getInnerDirPath(outputDir),
|
|
278
|
+
cleanupDir: () => {
|
|
279
|
+
return rm(tempDir, { recursive: true, force: true });
|
|
280
|
+
}
|
|
281
|
+
};
|
|
282
|
+
};
|
|
283
|
+
async function downloadZip(url, outputPath) {
|
|
284
|
+
const response = await fetch(url);
|
|
285
|
+
if (!response.ok) {
|
|
286
|
+
return { ok: false, error: "Failed to fetch the zip file" };
|
|
287
|
+
}
|
|
288
|
+
if (!response.body) {
|
|
289
|
+
return { ok: false, error: "Response body is empty" };
|
|
290
|
+
}
|
|
291
|
+
const nodeReadableStream = Readable.fromWeb(response.body);
|
|
292
|
+
await pipeline(nodeReadableStream, createWriteStream(outputPath));
|
|
293
|
+
return { ok: true };
|
|
294
|
+
}
|
|
295
|
+
var getInnerDirPath = (dirPath) => {
|
|
296
|
+
return new Promise((resolve, reject) => {
|
|
297
|
+
const files = fs3.readdirSync(dirPath);
|
|
298
|
+
const innerDir = files.find((f) => {
|
|
299
|
+
console.log("f", path3.join(dirPath, f));
|
|
300
|
+
return fs3.statSync(path3.join(dirPath, f)).isDirectory();
|
|
301
|
+
});
|
|
302
|
+
if (!innerDir) {
|
|
303
|
+
return reject("No inner directory found");
|
|
304
|
+
}
|
|
305
|
+
resolve(path3.join(dirPath, innerDir));
|
|
306
|
+
});
|
|
307
|
+
};
|
|
308
|
+
|
|
309
|
+
// trpc/functionality/overview.ts
|
|
310
|
+
var getOverview = (dirPath) => {
|
|
311
|
+
const monorepoInfo = getMonorepoInfo(dirPath);
|
|
312
|
+
if (!monorepoInfo) {
|
|
313
|
+
return null;
|
|
314
|
+
}
|
|
315
|
+
const workspacesMap = monorepoInfo.workspaces.reduce(
|
|
316
|
+
(acc, { workspace }) => {
|
|
317
|
+
acc[workspace.name] = workspace;
|
|
318
|
+
return acc;
|
|
319
|
+
},
|
|
320
|
+
{}
|
|
321
|
+
);
|
|
322
|
+
const dependencyLinks = monorepoInfo.workspaces.map(({ workspace }) => {
|
|
323
|
+
const internalDependencies = workspace.dependencies.filter((dep) => !!workspacesMap[dep.name]).map((v) => v.name);
|
|
324
|
+
return {
|
|
325
|
+
workspaceName: workspace.name,
|
|
326
|
+
internalDependencies
|
|
327
|
+
};
|
|
328
|
+
});
|
|
329
|
+
const getDependencyType = (workspace) => {
|
|
330
|
+
const hasDecendants = dependencyLinks.find((v) => v.workspaceName === workspace).internalDependencies.length > 0;
|
|
331
|
+
const hasAncestors = dependencyLinks.filter((v) => {
|
|
332
|
+
if (v.workspaceName === workspace)
|
|
333
|
+
return false;
|
|
334
|
+
if (v.internalDependencies.includes(workspace))
|
|
335
|
+
return true;
|
|
336
|
+
return false;
|
|
337
|
+
}).length > 0;
|
|
338
|
+
if (hasDecendants && hasAncestors) {
|
|
339
|
+
return "internal";
|
|
340
|
+
}
|
|
341
|
+
if (hasAncestors) {
|
|
342
|
+
return "leaf";
|
|
343
|
+
}
|
|
344
|
+
return "standalone";
|
|
345
|
+
};
|
|
346
|
+
return dependencyLinks.map((link) => {
|
|
347
|
+
return {
|
|
348
|
+
...link,
|
|
349
|
+
dependenciesCount: workspacesMap[link.workspaceName].dependencies.length,
|
|
350
|
+
type: getDependencyType(link.workspaceName)
|
|
351
|
+
};
|
|
352
|
+
});
|
|
353
|
+
};
|
|
354
|
+
|
|
355
|
+
// trpc/functionality/sync-updates.ts
|
|
356
|
+
var getSyncUpdates = (dirPath) => {
|
|
357
|
+
const monorepoInfo = getMonorepoInfo(dirPath);
|
|
358
|
+
if (!monorepoInfo) {
|
|
359
|
+
return null;
|
|
360
|
+
}
|
|
361
|
+
const workspaceMap = monorepoInfo.workspaces.reduce(
|
|
362
|
+
(acc, { workspace }) => {
|
|
363
|
+
acc[workspace.name] = true;
|
|
364
|
+
return acc;
|
|
365
|
+
},
|
|
366
|
+
{}
|
|
367
|
+
);
|
|
368
|
+
return monorepoInfo.workspaces.flatMap(({ workspace }) => {
|
|
369
|
+
return workspace.dependencies.map((dependency) => {
|
|
370
|
+
return {
|
|
371
|
+
dependencyName: dependency.name,
|
|
372
|
+
dependencyType: dependency.type,
|
|
373
|
+
workspaceName: workspace.name,
|
|
374
|
+
versionRange: dependency.versionRange,
|
|
375
|
+
isInternalDependency: !!workspaceMap[dependency.name]
|
|
376
|
+
};
|
|
377
|
+
});
|
|
378
|
+
});
|
|
379
|
+
};
|
|
380
|
+
|
|
381
|
+
// trpc/functionality/sync-versions.ts
|
|
382
|
+
var syncVersions = (dirPath, updates) => {
|
|
383
|
+
const monorepoInfo = getMonorepoInfo(dirPath);
|
|
384
|
+
if (!monorepoInfo) {
|
|
385
|
+
return null;
|
|
386
|
+
}
|
|
387
|
+
return syncDependencyVersions(monorepoInfo, updates);
|
|
388
|
+
};
|
|
389
|
+
|
|
390
|
+
// trpc/setup.ts
|
|
391
|
+
import { initTRPC } from "@trpc/server";
|
|
392
|
+
var t = initTRPC.create();
|
|
393
|
+
var router = t.router;
|
|
394
|
+
var publicProcedure = t.procedure;
|
|
395
|
+
|
|
396
|
+
// trpc/server.ts
|
|
397
|
+
var appRouter = router({
|
|
398
|
+
helloWorld: publicProcedure.query(async () => {
|
|
399
|
+
return "Hello, World!";
|
|
400
|
+
}),
|
|
401
|
+
getOverview: publicProcedure.input(
|
|
402
|
+
z5.object({
|
|
403
|
+
type: z5.union([z5.literal("filepath"), z5.literal("url")]),
|
|
404
|
+
value: z5.string()
|
|
405
|
+
})
|
|
406
|
+
).query(async ({ input }) => {
|
|
407
|
+
const { type, value } = input;
|
|
408
|
+
if (type === "filepath") {
|
|
409
|
+
const dirPath = value;
|
|
410
|
+
const result = getOverview(dirPath);
|
|
411
|
+
return {
|
|
412
|
+
success: true,
|
|
413
|
+
result
|
|
414
|
+
};
|
|
415
|
+
} else {
|
|
416
|
+
const { projectDir, cleanupDir } = await downloadGitRepo(value);
|
|
417
|
+
const result = getOverview(projectDir);
|
|
418
|
+
await cleanupDir();
|
|
419
|
+
return {
|
|
420
|
+
success: true,
|
|
421
|
+
result
|
|
422
|
+
};
|
|
423
|
+
}
|
|
424
|
+
}),
|
|
425
|
+
getSyncUpdates: publicProcedure.input(
|
|
426
|
+
z5.object({
|
|
427
|
+
type: z5.union([z5.literal("filepath"), z5.literal("url")]),
|
|
428
|
+
value: z5.string()
|
|
429
|
+
})
|
|
430
|
+
).query(async ({ input }) => {
|
|
431
|
+
const { type, value } = input;
|
|
432
|
+
if (type === "filepath") {
|
|
433
|
+
const dirPath = value;
|
|
434
|
+
const result = getSyncUpdates(dirPath);
|
|
435
|
+
return {
|
|
436
|
+
success: true,
|
|
437
|
+
result
|
|
438
|
+
};
|
|
439
|
+
} else {
|
|
440
|
+
const { projectDir, cleanupDir } = await downloadGitRepo(value);
|
|
441
|
+
const result = getSyncUpdates(projectDir);
|
|
442
|
+
await cleanupDir();
|
|
443
|
+
return {
|
|
444
|
+
success: true,
|
|
445
|
+
result
|
|
446
|
+
};
|
|
447
|
+
}
|
|
448
|
+
}),
|
|
449
|
+
syncDependencies: publicProcedure.input(
|
|
450
|
+
z5.object({
|
|
451
|
+
dirPath: z5.string(),
|
|
452
|
+
updates: z5.array(
|
|
453
|
+
z5.object({
|
|
454
|
+
dependencyName: z5.string(),
|
|
455
|
+
versionRange: z5.string()
|
|
456
|
+
})
|
|
457
|
+
)
|
|
458
|
+
})
|
|
459
|
+
).mutation(async ({ input }) => {
|
|
460
|
+
const result = syncVersions(input.dirPath, input.updates);
|
|
461
|
+
return result;
|
|
462
|
+
})
|
|
463
|
+
});
|
|
464
|
+
|
|
465
|
+
// cli.ts
|
|
466
|
+
var __DIRNAME = fileURLToPath(new URL(".", import.meta.url));
|
|
467
|
+
var app = express();
|
|
468
|
+
app.use(
|
|
469
|
+
"/api",
|
|
470
|
+
trpcExpress.createExpressMiddleware({
|
|
471
|
+
router: appRouter
|
|
472
|
+
})
|
|
473
|
+
);
|
|
474
|
+
app.use(express.static("dist"));
|
|
475
|
+
app.get("*", (_, res) => {
|
|
476
|
+
res.sendFile(path4.join(__DIRNAME, "dist", "index.html"));
|
|
477
|
+
});
|
|
478
|
+
var port = 21212;
|
|
479
|
+
app.listen(port, () => {
|
|
480
|
+
console.log(`Server listening... http://localhost:${port}/`);
|
|
481
|
+
});
|
package/dist/index.html
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
+
<title>monoverse</title>
|
|
8
|
+
<script type="module" crossorigin src="/assets/index-UQPMV9jG.js"></script>
|
|
9
|
+
<link rel="stylesheet" crossorigin href="/assets/index-DIUWvkwu.css">
|
|
10
|
+
</head>
|
|
11
|
+
<body class="dark">
|
|
12
|
+
<div id="root"></div>
|
|
13
|
+
</body>
|
|
14
|
+
</html>
|
package/dist/vite.svg
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
|