@alcedocore/cli 0.0.1-rc.0

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 (70) hide show
  1. package/LICENSE.md +102 -0
  2. package/dist/commands/add-endpoint.js +104 -0
  3. package/dist/commands/add-migration.js +80 -0
  4. package/dist/commands/add-nav-item.js +72 -0
  5. package/dist/commands/add-page.js +64 -0
  6. package/dist/commands/build-frontend.js +126 -0
  7. package/dist/commands/compile-pages.js +120 -0
  8. package/dist/commands/connect.js +122 -0
  9. package/dist/commands/deploy.js +74 -0
  10. package/dist/commands/dev.js +13 -0
  11. package/dist/commands/init-core.js +900 -0
  12. package/dist/commands/init.js +124 -0
  13. package/dist/commands/init.test.js +84 -0
  14. package/dist/commands/migrate.js +22 -0
  15. package/dist/commands/proxy.js +157 -0
  16. package/dist/commands/publish.js +81 -0
  17. package/dist/commands/replay.js +142 -0
  18. package/dist/commands/serve-frontend.js +92 -0
  19. package/dist/config.js +110 -0
  20. package/dist/config.test.js +48 -0
  21. package/dist/index.js +81 -0
  22. package/dist/integration/cli-api.test.js +116 -0
  23. package/dist/utils/ejs-renderer.js +46 -0
  24. package/dist/utils/ejs-renderer.test.js +93 -0
  25. package/dist/utils/formatting.js +65 -0
  26. package/dist/utils/generateTimestamp.js +17 -0
  27. package/dist/utils/logger.js +33 -0
  28. package/dist/utils/validation.js +15 -0
  29. package/package.json +41 -0
  30. package/src/commands/add-endpoint.ts +157 -0
  31. package/src/commands/add-migration.ts +102 -0
  32. package/src/commands/add-nav-item.ts +106 -0
  33. package/src/commands/add-page.ts +100 -0
  34. package/src/commands/build-frontend.ts +148 -0
  35. package/src/commands/connect.ts +98 -0
  36. package/src/commands/deploy.ts +85 -0
  37. package/src/commands/dev.ts +12 -0
  38. package/src/commands/init-core.ts +1019 -0
  39. package/src/commands/init.test.ts +92 -0
  40. package/src/commands/init.ts +171 -0
  41. package/src/commands/migrate.ts +20 -0
  42. package/src/commands/proxy.ts +206 -0
  43. package/src/commands/publish.ts +106 -0
  44. package/src/commands/serve-frontend.ts +103 -0
  45. package/src/config.test.ts +50 -0
  46. package/src/config.ts +125 -0
  47. package/src/index.ts +100 -0
  48. package/src/integration/cli-api.test.ts +143 -0
  49. package/src/utils/ejs-renderer.ts +55 -0
  50. package/src/utils/formatting.ts +62 -0
  51. package/src/utils/generateTimestamp.ts +16 -0
  52. package/src/utils/logger.ts +27 -0
  53. package/src/utils/validation.ts +13 -0
  54. package/templates/endpoint/handler.js.ejs +23 -0
  55. package/templates/endpoint/handler.py.ejs +23 -0
  56. package/templates/migration/down.sql.ejs +6 -0
  57. package/templates/migration/up.sql.ejs +11 -0
  58. package/templates/page/page.vue.ejs +63 -0
  59. package/templates/plugin/Dockerfile.ejs +13 -0
  60. package/templates/plugin/Dockerfile.node.ejs +14 -0
  61. package/templates/plugin/README.md.ejs +19 -0
  62. package/templates/plugin/gitignore.ejs +6 -0
  63. package/templates/plugin/manifest.json.ejs +18 -0
  64. package/templates/plugin/migrations/.gitkeep +0 -0
  65. package/templates/plugin/pages/.gitkeep +0 -0
  66. package/templates/plugin/public/.gitkeep +0 -0
  67. package/templates/plugin/server.js.ejs +27 -0
  68. package/templates/plugin/server.py.ejs +32 -0
  69. package/tsconfig.json +16 -0
  70. package/vitest.config.ts +14 -0
@@ -0,0 +1,63 @@
1
+ <!-- Generated by alcedo add page <%- name %> -->
2
+ <script setup lang="ts">
3
+ import { ref, onMounted } from 'vue'
4
+
5
+ // SDK injection: use window.AlcedoSDK (global) or provide/inject pattern
6
+ // To use provide/inject instead:
7
+ // import { inject } from 'vue'
8
+ // const sdk = inject('alcedo-sdk')
9
+ const sdk = window.AlcedoSDK
10
+
11
+ const loading = ref(true)
12
+ const data = ref(null)
13
+
14
+ onMounted(async () => {
15
+ try {
16
+ // Replace with your actual API call:
17
+ // data.value = await sdk.fetch('/api/<%- name %>')
18
+ data.value = { status: 'ready', page: '<%- name %>' }
19
+ } catch (e) {
20
+ console.error('Failed to load page data', e)
21
+ } finally {
22
+ loading.value = false
23
+ }
24
+ })
25
+ </script>
26
+
27
+ <template>
28
+ <div class="alcedo-<%- name %>-page">
29
+ <div v-if="loading" class="loading">Loading...</div>
30
+ <div v-else-if="data" class="content">
31
+ <h1><%- label %></h1>
32
+ <p>
33
+ This page was generated by
34
+ <code>alcedo add page <%- name %></code>.
35
+ </p>
36
+ <!-- Register this page in pages/main.ts: import and add to the pages array -->
37
+ <pre>{{ data }}</pre>
38
+ </div>
39
+ </div>
40
+ </template>
41
+
42
+ <style scoped>
43
+ .alcedo-<%- name %>-page {
44
+ padding: 1.5rem;
45
+ }
46
+ .loading {
47
+ color: var(--text-muted);
48
+ padding: 2rem;
49
+ text-align: center;
50
+ }
51
+ .content {
52
+ max-width: 800px;
53
+ }
54
+ h1 {
55
+ margin-bottom: 1rem;
56
+ }
57
+ pre {
58
+ background: var(--bg-code, #f5f5f5);
59
+ padding: 1rem;
60
+ border-radius: 4px;
61
+ overflow-x: auto;
62
+ }
63
+ </style>
@@ -0,0 +1,13 @@
1
+ FROM python:3.11-slim
2
+
3
+ WORKDIR /app
4
+
5
+ COPY server.py .
6
+ COPY public/ ./public/
7
+ COPY migrations/ ./migrations/
8
+ COPY pages/dist/ ./pages/dist/
9
+ COPY manifest.json .
10
+
11
+ EXPOSE 8080
12
+
13
+ CMD ["python", "server.py"]
@@ -0,0 +1,14 @@
1
+ FROM node:20-slim
2
+
3
+ WORKDIR /app
4
+
5
+ COPY server.js .
6
+ COPY endpoints/ ./endpoints/
7
+ COPY public/ ./public/
8
+ COPY migrations/ ./migrations/
9
+ COPY pages/dist/ ./pages/dist/
10
+ COPY manifest.json .
11
+
12
+ EXPOSE 8080
13
+
14
+ CMD ["node", "server.js"]
@@ -0,0 +1,19 @@
1
+ # <%= name %>
2
+
3
+ A plugin for Alcedo.
4
+
5
+ ## Getting Started
6
+
7
+ ```bash
8
+ # Build and deploy
9
+ docker build -t localhost:5000/<%= slug %>:1.0.0 .
10
+ docker push localhost:5000/<%= slug %>:1.0.0
11
+ ```
12
+
13
+ ## Development
14
+
15
+ Run locally during development:
16
+
17
+ ```bash
18
+ python server.py
19
+ ```
@@ -0,0 +1,6 @@
1
+ node_modules/
2
+ dist/
3
+ pages/dist/
4
+ __pycache__/
5
+ *.pyc
6
+ .DS_Store
@@ -0,0 +1,18 @@
1
+ {
2
+ "name": "<%= name %>",
3
+ "version": "<%= version || '1.0.0' %>",
4
+ "plugin_type": "docker",
5
+ "system_plugin": false,
6
+ "image": "<%= registryUrl %>/<%= slug %>:1.0.0",
7
+ "env": {},
8
+ "resources": {},
9
+ "pages": [],
10
+ "endpoints": [
11
+ {
12
+ "method": "GET",
13
+ "path": "/health",
14
+ "description": "Health check endpoint",
15
+ "group": "system"
16
+ }
17
+ ]
18
+ }
File without changes
File without changes
File without changes
@@ -0,0 +1,27 @@
1
+ const http = require("http");
2
+ const url = require("url");
3
+
4
+ const server = http.createServer((req, res) => {
5
+ const parsed = url.parse(req.url);
6
+ const path = parsed.pathname;
7
+
8
+ const sendJson = (data, status = 200) => {
9
+ const body = JSON.stringify(data);
10
+ res.writeHead(status, { "Content-Type": "application/json", "Content-Length": Buffer.byteLength(body) });
11
+ res.end(body);
12
+ };
13
+
14
+ if (path === "/health") {
15
+ sendJson({ status: "healthy" });
16
+ } else if (req.method === "GET") {
17
+ sendJson({ status: "ok", path });
18
+ } else if (req.method === "POST") {
19
+ sendJson({ status: "ok", method: "POST" });
20
+ } else {
21
+ sendJson({ error: "Method not allowed" }, 405);
22
+ }
23
+ });
24
+
25
+ server.listen(8080, "0.0.0.0", () => {
26
+ console.log("Plugin running on port 8080");
27
+ });
@@ -0,0 +1,32 @@
1
+ import json
2
+ from http.server import HTTPServer, BaseHTTPRequestHandler
3
+ from urllib.parse import urlparse
4
+
5
+
6
+ class Handler(BaseHTTPRequestHandler):
7
+ def do_GET(self):
8
+ parsed = urlparse(self.path)
9
+ path = parsed.path
10
+
11
+ if path == "/health":
12
+ self._json({"status": "healthy"})
13
+ else:
14
+ self._json({"status": "ok", "path": path})
15
+
16
+ def do_POST(self):
17
+ self._json({"status": "ok", "method": "POST"})
18
+
19
+ def _json(self, data, status=200):
20
+ self.send_response(status)
21
+ self.send_header("Content-Type", "application/json")
22
+ self.end_headers()
23
+ self.wfile.write(json.dumps(data).encode())
24
+
25
+ def log_message(self, format, *args):
26
+ pass
27
+
28
+
29
+ if __name__ == "__main__":
30
+ server = HTTPServer(("0.0.0.0", 8080), Handler)
31
+ print("Plugin running on port 8080")
32
+ server.serve_forever()
package/tsconfig.json ADDED
@@ -0,0 +1,16 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "commonjs",
5
+ "lib": ["ES2022"],
6
+ "outDir": "dist",
7
+ "rootDir": "src",
8
+ "strict": true,
9
+ "esModuleInterop": true,
10
+ "skipLibCheck": true,
11
+ "declaration": true,
12
+ "declarationMap": true,
13
+ "sourceMap": true
14
+ },
15
+ "include": ["src/**/*"]
16
+ }
@@ -0,0 +1,14 @@
1
+ import { defineConfig } from "vitest/config";
2
+
3
+ export default defineConfig({
4
+ test: {
5
+ globals: true,
6
+ environment: "node",
7
+ include: ["src/**/*.test.ts", "src/integration/**/*.test.ts"],
8
+ coverage: {
9
+ provider: "v8",
10
+ include: ["src/**/*.ts"],
11
+ exclude: ["src/**/*.test.ts", "src/index.ts"],
12
+ },
13
+ },
14
+ });