create-kuckit-app 0.1.0 → 0.1.1
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.
package/dist/bin.js
CHANGED
|
@@ -21,10 +21,10 @@ function isTokenExpired(config) {
|
|
|
21
21
|
return new Date(config.tokenExpiresAt) < /* @__PURE__ */ new Date();
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
24
|
-
* Checks if the user is authenticated
|
|
25
|
-
* Exits the process with an error message if not authenticated.
|
|
24
|
+
* Checks if the user is authenticated and has the required permission.
|
|
25
|
+
* Exits the process with an error message if not authenticated or permission is missing.
|
|
26
26
|
*/
|
|
27
|
-
function
|
|
27
|
+
function requirePermission(permission) {
|
|
28
28
|
const config = loadConfig();
|
|
29
29
|
if (!config?.cliToken) {
|
|
30
30
|
console.error("\nError: Not logged in. Run 'kuckit auth login' first.\n");
|
|
@@ -34,12 +34,18 @@ function requireAuth() {
|
|
|
34
34
|
console.error("\nError: Session expired. Run 'kuckit auth login' to refresh.\n");
|
|
35
35
|
process.exit(1);
|
|
36
36
|
}
|
|
37
|
+
if (!config.permissions?.includes(permission)) {
|
|
38
|
+
console.error(`\nError: Permission denied. Required: '${permission}'`);
|
|
39
|
+
console.error(`Your permissions: ${config.permissions?.join(", ") || "(none)"}`);
|
|
40
|
+
console.error("Contact your administrator or re-login to refresh.\n");
|
|
41
|
+
process.exit(1);
|
|
42
|
+
}
|
|
37
43
|
}
|
|
38
44
|
|
|
39
45
|
//#endregion
|
|
40
46
|
//#region src/bin.ts
|
|
41
47
|
program.name("create-kuckit-app").description("Create a new Kuckit application").version("0.1.0").argument("<project-name>", "Name of the project to create").option("--skip-install", "Skip running package manager install", false).option("--template <template>", "Template to use", "base").action(async (projectName, options) => {
|
|
42
|
-
|
|
48
|
+
requirePermission("scaffold");
|
|
43
49
|
await createProject(projectName, options);
|
|
44
50
|
});
|
|
45
51
|
program.parse();
|
package/package.json
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import 'dotenv/config'
|
|
2
2
|
import express from 'express'
|
|
3
3
|
import cors from 'cors'
|
|
4
|
-
import { createKuckitContainer, loadKuckitModules } from '@kuckit/sdk'
|
|
5
|
-
import { getModuleSpecs } from './config/modules.js'
|
|
6
4
|
|
|
7
5
|
const app = express()
|
|
8
6
|
const port = process.env.PORT ?? 3000
|
|
@@ -10,30 +8,14 @@ const port = process.env.PORT ?? 3000
|
|
|
10
8
|
app.use(cors())
|
|
11
9
|
app.use(express.json())
|
|
12
10
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
})
|
|
11
|
+
// Health check
|
|
12
|
+
app.get('/health', (_req, res) => {
|
|
13
|
+
res.json({ status: 'ok' })
|
|
14
|
+
})
|
|
18
15
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
container,
|
|
22
|
-
env: process.env.NODE_ENV ?? 'development',
|
|
23
|
-
modules: getModuleSpecs(),
|
|
24
|
-
onComplete: () => {
|
|
25
|
-
console.log('All modules loaded')
|
|
26
|
-
},
|
|
27
|
-
})
|
|
16
|
+
// TODO: Kuckit SDK integration will be added in future version
|
|
17
|
+
// See: https://kuckit.dev/docs/getting-started
|
|
28
18
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
app.listen(port, () => {
|
|
35
|
-
console.log(`Server running at http://localhost:${port}`)
|
|
36
|
-
})
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
bootstrap().catch(console.error)
|
|
19
|
+
app.listen(port, () => {
|
|
20
|
+
console.log(`Server running at http://localhost:${port}`)
|
|
21
|
+
})
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { ModuleSpec } from '@kuckit/sdk'
|
|
2
|
-
import { kuckitModule as usersModule } from '@kuckit/users-module'
|
|
3
|
-
|
|
4
|
-
export const getModuleSpecs = (): ModuleSpec[] => {
|
|
5
|
-
const modules: ModuleSpec[] = [
|
|
6
|
-
{ module: usersModule },
|
|
7
|
-
|
|
8
|
-
// KUCKIT_MODULES_START
|
|
9
|
-
// Modules installed via 'kuckit add' will be added here
|
|
10
|
-
// KUCKIT_MODULES_END
|
|
11
|
-
]
|
|
12
|
-
|
|
13
|
-
return modules
|
|
14
|
-
}
|