2024-11-28 23:22:31 +00:00
|
|
|
/**
|
|
|
|
|
* @license
|
|
|
|
|
* Copyright Google LLC All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
|
|
|
* found in the LICENSE file at https://angular.dev/license
|
|
|
|
|
*/
|
|
|
|
|
|
2024-07-23 16:50:12 +00:00
|
|
|
import {FileSystemTree} from '@webcontainer/api';
|
2025-05-06 20:59:30 +00:00
|
|
|
import {FileAndContentRecord, TutorialConfig} from '../../interfaces/index';
|
|
|
|
|
import {getFileSystemTree} from './webcontainers.mjs';
|
2024-07-23 16:50:12 +00:00
|
|
|
|
|
|
|
|
/** Generate the source-code.json content for a provided tutorial config. */
|
|
|
|
|
export async function generateSourceCode(
|
|
|
|
|
config: TutorialConfig,
|
|
|
|
|
files: FileAndContentRecord,
|
|
|
|
|
): Promise<FileSystemTree> {
|
|
|
|
|
// TODO(josephperrott): figure out if filtering is needed for this.
|
|
|
|
|
const allFiles = Object.keys(files);
|
|
|
|
|
return getFileSystemTree(allFiles, files);
|
|
|
|
|
}
|