Skip to content

Commit

Permalink
Fixed issue in emulator
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianRappl committed Oct 15, 2024
1 parent d2d3eb1 commit a22c325
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/tooling/piral-cli/src/common/emulator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ async function makeExternals(sourceDir: string, piralPkg: any, externals: Array<
return [externalDependencies, importmapEntries, optionalDependencies] as const;
}

async function createScaffoldingTarballs(sourceDir: string, targetDir: string, files: Array<TemplateFileLocation>) {
async function createScaffoldingTarballs(sourceDir: string, targetDir: string, files: Array<string | TemplateFileLocation> = []) {
const filesDir = resolve(targetDir, filesTar);
const filesOnceDir = resolve(targetDir, filesOnceTar);

Expand All @@ -70,14 +70,14 @@ async function createScaffoldingTarballs(sourceDir: string, targetDir: string, f
await copyScaffoldingFiles(
sourceDir,
filesDir,
files.filter((m) => !m.once),
files.filter((m) => typeof m === 'string' || !m.once),
);

// also to avoid information loss we should store the once-only files separately
await copyScaffoldingFiles(
sourceDir,
filesOnceDir,
files.filter((m) => m.once),
files.filter((m) => typeof m !== 'string' && m.once),
);

// since things like .gitignore are not properly treated by npm we pack the files (for standard and once only)
Expand All @@ -103,7 +103,6 @@ export async function createEmulatorSources(
...piralPkg.pilets,
...piralJsonPkg.pilets,
};
const files = makeFilesMap(pilets.files);
const allDeps = {
...piralPkg.devDependencies,
...piralPkg.dependencies,
Expand Down Expand Up @@ -134,7 +133,7 @@ export async function createEmulatorSources(
},
pilets: {
...pilets,
files,
files: makeFilesMap(pilets.files),
},
piralCLI: {
version: cliVersion,
Expand Down Expand Up @@ -172,7 +171,7 @@ export async function createEmulatorSources(
await createPiralDeclaration(sourceDir, piralPkg.app ?? `./src/index.html`, targetDir, ForceOverwrite.yes, logLevel);

// generate the files.tar and files_once.tar files
await createScaffoldingTarballs(sourceDir, rootDir, files);
await createScaffoldingTarballs(sourceDir, rootDir, pilets.files);

return rootDir;
}
Expand All @@ -190,7 +189,6 @@ export async function createEmulatorWebsite(
...piralPkg.pilets,
...piralJsonPkg.pilets,
};
const files = makeFilesMap(pilets.files);
const allDeps = {
...piralPkg.devDependencies,
...piralPkg.dependencies,
Expand All @@ -211,7 +209,7 @@ export async function createEmulatorWebsite(
scaffolding: {
pilets: {
...pilets,
files,
files: makeFilesMap(pilets.files),
},
cli: cliVersion,
},
Expand Down Expand Up @@ -241,7 +239,7 @@ export async function createEmulatorWebsite(
await createPiralDeclaration(sourceDir, piralPkg.app ?? `./src/index.html`, targetDir, ForceOverwrite.yes, logLevel);

// generate the files.tar and files_once.tar files
await createScaffoldingTarballs(sourceDir, targetDir, files);
await createScaffoldingTarballs(sourceDir, targetDir, pilets.files);

return targetDir;
}
Expand Down

0 comments on commit a22c325

Please sign in to comment.