turbo-web 4.2.5 → 4.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/bin/turbo-charge.js +55 -30
  2. package/package.json +1 -1
@@ -5,7 +5,6 @@ import '../dist/turbo.js';
5
5
  import fs from 'fs';
6
6
  import path from 'path';
7
7
 
8
- // 1. gets the project name from the terminal command
9
8
  const projectName = process.argv[2];
10
9
 
11
10
  if (!projectName) {
@@ -14,41 +13,67 @@ if (!projectName) {
14
13
  process.exit(1);
15
14
  }
16
15
 
17
- // 2. defines the target directory path
16
+ // defines the target directory path
18
17
  const projectPath = path.join(process.cwd(), projectName);
18
+ const srcPath = path.join(projectPath, 'src');
19
19
 
20
- // 3. creates the directories
20
+ // creates the directories
21
21
  fs.mkdirSync(projectPath, { recursive: true });
22
22
  fs.mkdirSync(path.join(projectPath, 'src'), { recursive: true });
23
23
 
24
- // 4. defines the boilerplate file contents
25
- const storeContent = `import { Store } from 'your-framework';
26
-
27
- export const appStore = new Store({
28
- state: {},
29
- mutations: {},
30
- actions: {}
31
- });
32
- `;
33
-
34
- const routerContent = `export function initRouter() {
35
- window.addEventListener('hashchange', () => {
36
- const path = window.location.hash.slice(1).toLowerCase() || '/';
37
- console.log('Navigated to:', path);
38
- // Add route matching and component mounting logic here
39
- });
40
- }
41
- `;
24
+ // auto initiating package.json
25
+ const packageJsonContent = {
26
+ name: projectName,
27
+ version: "1.0.0",
28
+ type: "module",
29
+ dependencies: {
30
+ "turbo-web": "latest"
31
+ },
32
+ scripts: {
33
+ "start": "npx serve ."
34
+ }
35
+ };
36
+
37
+ fs.writeFileSync(
38
+ path.join(projectPath, 'package.json'),
39
+ JSON.stringify(packageJsonContent, null, 2)
40
+ );
41
+
42
+ // defines the boilerplate file contents
43
+ const storeContent = `import { Store } from 'turbo-web';
44
+ export const appStore = new Store({ state: { count: 0 } });`;
45
+
46
+ const routerContent = `import { HashRouter } from 'turbo-web';
47
+ export const router = new HashRouter([{ path: '/', component: null }]);`;
48
+
49
+ const mainContent = `import { createApp, h } from 'turbo-web';
50
+ import { router } from './router.js';
51
+ import { appStore } from './store.js';
52
+
53
+ const App = { render: () => h('div', {}, ['Turbo Power!']) };
54
+ createApp(App, {}, { router, store: appStore }).mount(document.body);`;
55
+
56
+ // write the files to the user's new project directory
57
+ fs.writeFileSync(path.join(srcPath, 'store.js'), storeContent);
58
+ fs.writeFileSync(path.join(srcPath, 'router.js'), routerContent);
59
+ fs.writeFileSync(path.join(srcPath, 'main.js'), mainContent);
42
60
 
43
- const mainContent = `import { appStore } from './store.js';
44
- import { initRouter } from './router.js';
61
+ // defining HTML
62
+ const htmlContent = `<!DOCTYPE html>
63
+ <html>
64
+ <head><title>${projectName}</title></head>
65
+ <body>
66
+ <script type="module" src="./src/main.js"></script>
67
+ </body>
68
+ </html>`;
45
69
 
46
- initRouter();
47
- `;
70
+ fs.writeFileSync(path.join(projectPath, 'index.html'), htmlContent);
48
71
 
49
- // 5. Write the files to the user's new project directory
50
- fs.writeFileSync(path.join(projectPath, 'src', 'store.js'), storeContent);
51
- fs.writeFileSync(path.join(projectPath, 'src', 'router.js'), routerContent);
52
- fs.writeFileSync(path.join(projectPath, 'src', 'main.js'), mainContent);
72
+ console.log(`
73
+ BUENO! [${projectName}] is TURBO charged for WEB development.
53
74
 
54
- console.log(`BUENO! You project:${projectName} is TURBO charged for web development!`);
75
+ Next steps:
76
+ 1. cd ${projectName}
77
+ 2. npm install
78
+ "You are ready for development!"
79
+ `);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "turbo-web",
3
- "version": "4.2.5",
3
+ "version": "4.2.6",
4
4
  "main": "dist/turbo.js",
5
5
  "files": [
6
6
  "dist",