|
1 | 1 | import sdk from '@stackblitz/sdk';
|
2 |
| -// THIS IS OPTION FIVE - OPEN PROJECT (Creates a new project and opens it in a new tab (or in the current window).) |
3 |
| -// (project, openOptions) |
| 2 | + |
4 | 3 | export const createProject = async () => {
|
5 |
| - console.log('CREATE_PROJECT'); |
6 |
| - sdk.openProject( |
7 |
| - { |
8 |
| - title: 'Banana Project', |
9 |
| - description: 'Blank starter project for building ES6 apps.', |
10 |
| - template: 'javascript', |
11 |
| - files: { |
12 |
| - 'index.html': `<div id='app'></div>`, |
13 |
| - 'index.js': `import './style.css'; |
14 |
| -const appDiv = document.getElementById('app'); |
15 |
| -appDiv.innerHTML = '<h1>JS Starter</h1>';`, |
16 |
| - 'style.css': `body { font-family: system-ui, sans-serif; }`, |
17 |
| - }, |
18 |
| - settings: { |
19 |
| - compile: { |
20 |
| - trigger: 'auto', |
21 |
| - clearConsole: false, |
| 4 | + try { |
| 5 | + await sdk.embedProject( |
| 6 | + 'stackblitz', |
| 7 | + { |
| 8 | + title: 'Node Starter', |
| 9 | + description: 'A basic Node.js project', |
| 10 | + template: 'node', |
| 11 | + files: { |
| 12 | + 'index.js': `console.log('Hello World!');`, |
| 13 | + 'package.json': `{ |
| 14 | + "name": "my-project", |
| 15 | + "scripts": { "hello": "node index.js", "start": "serve node_modules" }, |
| 16 | + "dependencies": { "serve": "^14.0.0" }, |
| 17 | + "stackblitz": { "installDependencies": true, "startCommand": "npm start" }, |
| 18 | + }`, |
22 | 19 | },
|
23 | 20 | },
|
24 |
| - }, |
25 |
| - { |
26 |
| - newWindow: false, |
27 |
| - openFile: ['index.js', 'index.html,style.css'], |
28 |
| - } |
29 |
| - ); |
| 21 | + { |
| 22 | + clickToLoad: true, |
| 23 | + openFile: 'index.js', |
| 24 | + terminalHeight: 50, |
| 25 | + } |
| 26 | + ); |
| 27 | + } catch (e) { |
| 28 | + console.log('ERROR_CAUGHT: ', e); |
| 29 | + } |
30 | 30 | };
|
0 commit comments