mirror of
https://github.com/noodlapp/noodl.git
synced 2026-01-11 14:52:53 +01:00
Initial commit
Co-Authored-By: Eric Tuvesson <eric.tuvesson@gmail.com> Co-Authored-By: mikaeltellhed <2311083+mikaeltellhed@users.noreply.github.com> Co-Authored-By: kotte <14197736+mrtamagotchi@users.noreply.github.com> Co-Authored-By: Anders Larsson <64838990+anders-topp@users.noreply.github.com> Co-Authored-By: Johan <4934465+joolsus@users.noreply.github.com> Co-Authored-By: Tore Knudsen <18231882+torekndsn@users.noreply.github.com> Co-Authored-By: victoratndl <99176179+victoratndl@users.noreply.github.com>
This commit is contained in:
77
scripts/noodl-editor/build-viewer.ts
Normal file
77
scripts/noodl-editor/build-viewer.ts
Normal file
@@ -0,0 +1,77 @@
|
||||
import { execSync } from 'child_process';
|
||||
import path from 'path';
|
||||
|
||||
// HACK :)
|
||||
import { FileSystemNode } from '../../packages/noodl-platform-node/src/filesystem-node';
|
||||
|
||||
async function buildViewer({ name, relativePath }) {
|
||||
// Inputs
|
||||
const WORKSPACE_PATH = path.resolve(__dirname, '../..');
|
||||
|
||||
// Variables
|
||||
const noodlViewerPath = path.join(WORKSPACE_PATH, 'packages/' + relativePath);
|
||||
const noodlEditorPath = path.join(WORKSPACE_PATH, 'packages', 'noodl-editor');
|
||||
const destination = path.join(noodlEditorPath, 'src', 'external');
|
||||
|
||||
// Debug Configuration
|
||||
console.log('--- Configuration');
|
||||
console.log('> WORKSPACE_PATH: ', WORKSPACE_PATH);
|
||||
console.log('---');
|
||||
console.log('> noodlViewerPath: ', noodlViewerPath);
|
||||
console.log('> noodlEditorPath: ', noodlEditorPath);
|
||||
console.log('> destination: ', destination);
|
||||
console.log('---');
|
||||
|
||||
// Install dependencies
|
||||
console.log("--- Run 'npm install' (cwd: ", noodlViewerPath, ') ...');
|
||||
execSync('npm i', {
|
||||
cwd: noodlViewerPath,
|
||||
stdio: 'inherit',
|
||||
env: {
|
||||
...process.env
|
||||
}
|
||||
});
|
||||
console.log("--- 'npm install' done!");
|
||||
|
||||
// Build
|
||||
console.log("--- Run 'npm run build' (cwd: ", noodlViewerPath, ') ...');
|
||||
execSync(`npx lerna exec --scope ${name} -- npm run build`, {
|
||||
cwd: WORKSPACE_PATH,
|
||||
stdio: 'inherit',
|
||||
env: {
|
||||
...process.env,
|
||||
OUTPUT_PATH: destination
|
||||
}
|
||||
});
|
||||
console.log("--- 'npm run build' done!");
|
||||
|
||||
// Display result
|
||||
const filesystem = new FileSystemNode();
|
||||
const files = await filesystem.listDirectoryFiles(destination);
|
||||
console.log('--- List build files:');
|
||||
files.forEach((file, index) => {
|
||||
console.log(index, file.fullPath);
|
||||
});
|
||||
|
||||
// Clean up
|
||||
console.log('--- Clean up ...');
|
||||
execSync(`npx lerna clean --yes --scope ${name}`, {
|
||||
stdio: 'inherit',
|
||||
env: {
|
||||
...process.env
|
||||
}
|
||||
});
|
||||
console.log('--- Clean up done!');
|
||||
}
|
||||
|
||||
(async function () {
|
||||
await buildViewer({
|
||||
relativePath: 'noodl-viewer-react',
|
||||
name: '@noodl/noodl-viewer-react'
|
||||
});
|
||||
|
||||
await buildViewer({
|
||||
relativePath: 'noodl-viewer-cloud',
|
||||
name: '@noodl/cloud-runtime'
|
||||
});
|
||||
})();
|
||||
Reference in New Issue
Block a user