mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-05 16:23:36 +00:00
Run build and install together (it works wtf!!!!)
This commit is contained in:
2 files changed
+18
-18
No files matched your search
@@ -77,18 +77,19 @@ export function ChatPane({ projectId, projectName }: ChatPaneProps) {
|
||||
const proc = await webcontainer.spawn('npm', ['i']);
|
||||
await proc.exit;
|
||||
|
||||
console.log(await webcontainer.fs.readdir('.'));
|
||||
const proc2 = await webcontainer.spawn('npm', ['run', 'build']);
|
||||
await proc2.exit;
|
||||
|
||||
// Copy "node_modules" out of the webcontainer back to the project directory
|
||||
const copyNodeModules = async () => {
|
||||
// Copy "dist" out of the webcontainer back to the project directory
|
||||
const copyDist = async () => {
|
||||
try {
|
||||
// Read the node_modules directory from webcontainer
|
||||
const nodeModulesContents = await webcontainer.fs.readdir('node_modules', { withFileTypes: true });
|
||||
// Read the dist directory from webcontainer
|
||||
const distContents = await webcontainer.fs.readdir('dist', { withFileTypes: true });
|
||||
|
||||
// Create node_modules directory in project if it doesn't exist
|
||||
const nodeModulesPath = `/projects/${projectId}/node_modules`;
|
||||
// Create dist directory in project if it doesn't exist
|
||||
const distPath = `/projects/${projectId}/dist`;
|
||||
try {
|
||||
await fsManager.fs.promises.mkdir(nodeModulesPath);
|
||||
await fsManager.fs.promises.mkdir(distPath);
|
||||
} catch {
|
||||
// Directory might already exist, that's fine
|
||||
}
|
||||
@@ -123,10 +124,10 @@ export function ChatPane({ projectId, projectName }: ChatPaneProps) {
|
||||
}
|
||||
};
|
||||
|
||||
// Copy each package in node_modules
|
||||
for (const item of nodeModulesContents) {
|
||||
const sourcePath = `node_modules/${item.name}`;
|
||||
const destPath = `${nodeModulesPath}/${item.name}`;
|
||||
// Copy each package in dist
|
||||
for (const item of distContents) {
|
||||
const sourcePath = `dist/${item.name}`;
|
||||
const destPath = `${distPath}/${item.name}`;
|
||||
|
||||
try {
|
||||
if (item.isDirectory()) {
|
||||
@@ -149,9 +150,7 @@ export function ChatPane({ projectId, projectName }: ChatPaneProps) {
|
||||
}
|
||||
};
|
||||
|
||||
await copyNodeModules();
|
||||
|
||||
// const buildProcess = await webcontainer.spawn('npm', ['run', 'build']);
|
||||
await copyDist();
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
+4
-3
@@ -8,6 +8,9 @@ if (typeof window !== 'undefined') {
|
||||
(window as { Buffer?: typeof Buffer }).Buffer = Buffer;
|
||||
}
|
||||
|
||||
// const GIT_TEMPLATE_URL = 'https://relay.ngit.dev/npub1q3sle0kvfsehgsuexttt3ugjd8xdklxfwwkh559wxckmzddywnws6cd26p/mkstack.git';
|
||||
const GIT_TEMPLATE_URL = 'https://relay.ngit.dev/npub1q3sle0kvfsehgsuexttt3ugjd8xdklxfwwkh559wxckmzddywnws6cd26p/lovable-blank.git';
|
||||
|
||||
export interface Project {
|
||||
id: string;
|
||||
name: string;
|
||||
@@ -60,14 +63,12 @@ export class FileSystemManager {
|
||||
}
|
||||
|
||||
async cloneTemplate(projectPath: string) {
|
||||
const templateUrl = 'https://relay.ngit.dev/npub1q3sle0kvfsehgsuexttt3ugjd8xdklxfwwkh559wxckmzddywnws6cd26p/mkstack.git';
|
||||
|
||||
try {
|
||||
await git.clone({
|
||||
fs: this.fs,
|
||||
http,
|
||||
dir: projectPath,
|
||||
url: templateUrl,
|
||||
url: GIT_TEMPLATE_URL,
|
||||
singleBranch: true,
|
||||
depth: 1,
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user