create-mdsn 0.3.3 → 0.4.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.
- package/LICENSE +21 -0
- package/README.md +25 -0
- package/dist/cli.d.ts +10 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +86 -14
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -4
- package/dist/index.js.map +1 -1
- package/package.json +13 -5
- package/template/bun/README.md +31 -0
- package/template/bun/index.mjs +63 -0
- package/template/bun/package.json +17 -0
- package/template/{starter → node}/README.md +1 -1
- package/template/{starter → node}/index.mjs +2 -2
- package/template/{starter → node}/package.json +1 -1
- /package/template/{starter → shared}/app/client.ts +0 -0
- /package/template/{starter → shared}/app/index.md +0 -0
- /package/template/{starter → shared}/app/server.ts +0 -0
- /package/template/{starter → shared}/tsconfig.json +0 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 MDSN
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -4,8 +4,12 @@
|
|
|
4
4
|
|
|
5
5
|
Use it when you want the fastest path from a blank directory to a working MDSN app.
|
|
6
6
|
|
|
7
|
+
It supports both Node and Bun starters.
|
|
8
|
+
|
|
7
9
|
## Usage
|
|
8
10
|
|
|
11
|
+
Node starter:
|
|
12
|
+
|
|
9
13
|
```bash
|
|
10
14
|
npm create mdsn@latest agent-app
|
|
11
15
|
cd agent-app
|
|
@@ -13,6 +17,27 @@ npm install
|
|
|
13
17
|
npm start
|
|
14
18
|
```
|
|
15
19
|
|
|
20
|
+
Bun starter:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
bunx create-mdsn agent-app
|
|
24
|
+
cd agent-app
|
|
25
|
+
bun install
|
|
26
|
+
bun start
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
You can override the generated runtime explicitly:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
npm create mdsn@latest agent-app -- --runtime bun
|
|
33
|
+
bunx create-mdsn agent-app --runtime node
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Defaults:
|
|
37
|
+
|
|
38
|
+
- `npm create` and `npx create-mdsn` default to the Node starter
|
|
39
|
+
- `bunx create-mdsn` defaults to the Bun starter
|
|
40
|
+
|
|
16
41
|
The generated app uses this small shape:
|
|
17
42
|
|
|
18
43
|
- `app/index.md`
|
package/dist/cli.d.ts
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
2
|
+
import { type StarterRuntime } from "./index.js";
|
|
3
|
+
export interface ParsedCliArgs {
|
|
4
|
+
targetArg: string | undefined;
|
|
5
|
+
runtime: StarterRuntime;
|
|
6
|
+
showHelp: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare function detectDefaultRuntime(userAgent?: string): StarterRuntime;
|
|
9
|
+
export declare function parseCliArgs(argv: string[], userAgent?: string): ParsedCliArgs;
|
|
10
|
+
export declare function formatUsage(): string;
|
|
11
|
+
export declare function formatNextSteps(projectDir: string, runtime: StarterRuntime, targetArg?: string): string;
|
|
3
12
|
//# sourceMappingURL=cli.d.ts.map
|
package/dist/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAKA,OAAO,EAA0B,KAAK,cAAc,EAAE,MAAM,YAAY,CAAC;AAEzE,MAAM,WAAW,aAAa;IAC5B,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,OAAO,EAAE,cAAc,CAAC;IACxB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAMD,wBAAgB,oBAAoB,CAAC,SAAS,SAA0C,GAAG,cAAc,CAExG;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,SAAS,SAA0C,GAAG,aAAa,CAkD/G;AAED,wBAAgB,WAAW,IAAI,MAAM,CAQpC;AAED,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,EAAE,SAAS,SAAa,GAAG,MAAM,CAa3G"}
|
package/dist/cli.js
CHANGED
|
@@ -1,12 +1,84 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { resolve } from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
3
4
|
import { scaffoldStarterProject } from "./index.js";
|
|
5
|
+
function isStarterRuntime(value) {
|
|
6
|
+
return value === "node" || value === "bun";
|
|
7
|
+
}
|
|
8
|
+
export function detectDefaultRuntime(userAgent = process.env.npm_config_user_agent ?? "") {
|
|
9
|
+
return /\bbun\/\d/i.test(userAgent) ? "bun" : "node";
|
|
10
|
+
}
|
|
11
|
+
export function parseCliArgs(argv, userAgent = process.env.npm_config_user_agent ?? "") {
|
|
12
|
+
let targetArg;
|
|
13
|
+
let runtime = detectDefaultRuntime(userAgent);
|
|
14
|
+
let showHelp = false;
|
|
15
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
16
|
+
const arg = argv[index];
|
|
17
|
+
if (!arg) {
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
if (arg === "--help" || arg === "-h") {
|
|
21
|
+
showHelp = true;
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
if (arg === "--") {
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
if (arg === "--runtime") {
|
|
28
|
+
const next = argv[index + 1];
|
|
29
|
+
if (!next || !isStarterRuntime(next)) {
|
|
30
|
+
throw new Error('Expected "--runtime" to be followed by "node" or "bun".');
|
|
31
|
+
}
|
|
32
|
+
runtime = next;
|
|
33
|
+
index += 1;
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
if (arg.startsWith("--runtime=")) {
|
|
37
|
+
const value = arg.slice("--runtime=".length);
|
|
38
|
+
if (!isStarterRuntime(value)) {
|
|
39
|
+
throw new Error(`Unsupported runtime "${value}". Expected "node" or "bun".`);
|
|
40
|
+
}
|
|
41
|
+
runtime = value;
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
if (arg.startsWith("-")) {
|
|
45
|
+
throw new Error(`Unknown option "${arg}".`);
|
|
46
|
+
}
|
|
47
|
+
if (targetArg) {
|
|
48
|
+
throw new Error(`Unexpected extra argument "${arg}".`);
|
|
49
|
+
}
|
|
50
|
+
targetArg = arg;
|
|
51
|
+
}
|
|
52
|
+
return { targetArg, runtime, showHelp };
|
|
53
|
+
}
|
|
54
|
+
export function formatUsage() {
|
|
55
|
+
return [
|
|
56
|
+
"Usage:",
|
|
57
|
+
" npm create mdsn@latest <project-name>",
|
|
58
|
+
" npm create mdsn@latest <project-name> -- --runtime bun",
|
|
59
|
+
" bunx create-mdsn <project-name>",
|
|
60
|
+
" bunx create-mdsn <project-name> --runtime node"
|
|
61
|
+
].join("\n");
|
|
62
|
+
}
|
|
63
|
+
export function formatNextSteps(projectDir, runtime, targetArg = projectDir) {
|
|
64
|
+
const installCommand = runtime === "bun" ? "bun install" : "npm install";
|
|
65
|
+
const startCommand = runtime === "bun" ? "bun start" : "npm start";
|
|
66
|
+
return [
|
|
67
|
+
`Created MDSN ${runtime} starter in ${projectDir}`,
|
|
68
|
+
"",
|
|
69
|
+
"Next steps:",
|
|
70
|
+
` cd ${targetArg}`,
|
|
71
|
+
"",
|
|
72
|
+
` ${installCommand}`,
|
|
73
|
+
` ${startCommand}`
|
|
74
|
+
].join("\n");
|
|
75
|
+
}
|
|
4
76
|
function printUsage() {
|
|
5
|
-
console.log(
|
|
77
|
+
console.log(formatUsage());
|
|
6
78
|
}
|
|
7
79
|
async function main(argv) {
|
|
8
|
-
const
|
|
9
|
-
if (!targetArg ||
|
|
80
|
+
const { targetArg, runtime, showHelp } = parseCliArgs(argv);
|
|
81
|
+
if (!targetArg || showHelp) {
|
|
10
82
|
printUsage();
|
|
11
83
|
return;
|
|
12
84
|
}
|
|
@@ -14,17 +86,17 @@ async function main(argv) {
|
|
|
14
86
|
const projectDir = await scaffoldStarterProject({
|
|
15
87
|
targetDir,
|
|
16
88
|
sdkVersion: "latest",
|
|
89
|
+
runtime,
|
|
17
90
|
...(targetArg === "." ? {} : { projectName: targetArg })
|
|
18
91
|
});
|
|
19
|
-
console.log(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
});
|
|
92
|
+
console.log(formatNextSteps(projectDir, runtime, targetArg));
|
|
93
|
+
}
|
|
94
|
+
const entryPath = process.argv[1] ? resolve(process.argv[1]) : null;
|
|
95
|
+
const modulePath = resolve(fileURLToPath(import.meta.url));
|
|
96
|
+
if (entryPath === modulePath) {
|
|
97
|
+
main(process.argv.slice(2)).catch((error) => {
|
|
98
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
99
|
+
process.exitCode = 1;
|
|
100
|
+
});
|
|
101
|
+
}
|
|
30
102
|
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,sBAAsB,EAAuB,MAAM,YAAY,CAAC;AAQzE,SAAS,gBAAgB,CAAC,KAAa;IACrC,OAAO,KAAK,KAAK,MAAM,IAAI,KAAK,KAAK,KAAK,CAAC;AAC7C,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,qBAAqB,IAAI,EAAE;IACtF,OAAO,YAAY,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC;AACvD,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,IAAc,EAAE,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,qBAAqB,IAAI,EAAE;IAC9F,IAAI,SAA6B,CAAC;IAClC,IAAI,OAAO,GAAG,oBAAoB,CAAC,SAAS,CAAC,CA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CAAC,CAAC;IACpD,MAAM,UAAU,GAAG,MAAM,sBAAsB,CAAC;QAC9C,SAAS;QACT,UAAU,EAAE,QAAQ;QACpB,OAAO;QACP,GAAG,CAAC,SAAS,KAAK,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,SAAS,EAAE,CAAC;KACzD,CAAC,CAAC;IAEH,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,UAAU,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC;AAC/D,CAAC;AAED,MAAM,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AACpE,MAAM,UAAU,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAE3D,IAAI,SAAS,KAAK,UAAU,EAAE,CAAC;IAC7B,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;QAC1C,OAAO,CAAC,KAAK,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QACtE,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;IACvB,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
export type StarterRuntime = "node" | "bun";
|
|
1
2
|
export interface ScaffoldStarterProjectOptions {
|
|
2
3
|
targetDir: string;
|
|
3
4
|
projectName?: string;
|
|
4
5
|
sdkVersion: string;
|
|
6
|
+
runtime?: StarterRuntime;
|
|
5
7
|
}
|
|
6
8
|
export declare function scaffoldStarterProject(options: ScaffoldStarterProjectOptions, moduleUrl?: string): Promise<string>;
|
|
7
9
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,6BAA6B;IAC5C,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,KAAK,CAAC;AAE5C,MAAM,WAAW,6BAA6B;IAC5C,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,cAAc,CAAC;CAC1B;AA6DD,wBAAsB,sBAAsB,CAC1C,OAAO,EAAE,6BAA6B,EACtC,SAAS,SAAkB,GAC1B,OAAO,CAAC,MAAM,CAAC,CAuBjB"}
|
package/dist/index.js
CHANGED
|
@@ -5,8 +5,12 @@ const TEMPLATE_PLACEHOLDERS = {
|
|
|
5
5
|
__PROJECT_NAME__: "",
|
|
6
6
|
__SDK_VERSION__: ""
|
|
7
7
|
};
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
const DEFAULT_RUNTIME = "node";
|
|
9
|
+
function templateRootsFromModule(moduleUrl, runtime) {
|
|
10
|
+
return [
|
|
11
|
+
resolve(fileURLToPath(new URL("../template/shared", moduleUrl))),
|
|
12
|
+
resolve(fileURLToPath(new URL(`../template/${runtime}`, moduleUrl)))
|
|
13
|
+
];
|
|
10
14
|
}
|
|
11
15
|
async function ensureEmptyTarget(targetDir) {
|
|
12
16
|
try {
|
|
@@ -52,14 +56,17 @@ async function walkFiles(root) {
|
|
|
52
56
|
return files;
|
|
53
57
|
}
|
|
54
58
|
export async function scaffoldStarterProject(options, moduleUrl = import.meta.url) {
|
|
55
|
-
const
|
|
59
|
+
const runtime = options.runtime ?? DEFAULT_RUNTIME;
|
|
60
|
+
const templateRoots = templateRootsFromModule(moduleUrl, runtime);
|
|
56
61
|
const targetDir = resolve(options.targetDir);
|
|
57
62
|
const projectName = options.projectName?.trim() || basename(targetDir);
|
|
58
63
|
if (!projectName) {
|
|
59
64
|
throw new Error("Project name cannot be empty.");
|
|
60
65
|
}
|
|
61
66
|
await ensureEmptyTarget(targetDir);
|
|
62
|
-
|
|
67
|
+
for (const templateRoot of templateRoots) {
|
|
68
|
+
await cp(templateRoot, targetDir, { recursive: true });
|
|
69
|
+
}
|
|
63
70
|
const replacements = {
|
|
64
71
|
__PROJECT_NAME__: projectName,
|
|
65
72
|
__SDK_VERSION__: options.sdkVersion
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACjF,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACjF,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAWzC,MAAM,qBAAqB,GAAG;IAC5B,gBA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AAE,IAAI,QAAQ,CAAC,SAAS,CAAC,CAAC;IAEvE,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;IACnD,CAAC;IAED,MAAM,iBAAiB,CAAC,SAAS,CAAC,CAAC;IACnC,KAAK,MAAM,YAAY,IAAI,aAAa,EAAE,CAAC;QACzC,MAAM,EAAE,CAAC,YAAY,EAAE,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACzD,CAAC;IAED,MAAM,YAAY,GAAG;QACnB,gBAAgB,EAAE,WAAW;QAC7B,eAAe,EAAE,OAAO,CAAC,UAAU;KACpC,CAAC;IAEF,MAAM,KAAK,GAAG,MAAM,SAAS,CAAC,SAAS,CAAC,CAAC;IACzC,MAAM,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,aAAa,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC;IAClF,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-mdsn",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"private": false,
|
|
5
|
-
"description": "Create a minimal MDSN app with npm create.",
|
|
5
|
+
"description": "Create a minimal MDSN app with npm create or bunx.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://docs.mdsn.ai",
|
|
8
8
|
"bugs": {
|
|
@@ -23,7 +23,8 @@
|
|
|
23
23
|
"workflow",
|
|
24
24
|
"skills-app",
|
|
25
25
|
"agent-app",
|
|
26
|
-
"cli"
|
|
26
|
+
"cli",
|
|
27
|
+
"bun"
|
|
27
28
|
],
|
|
28
29
|
"type": "module",
|
|
29
30
|
"main": "./dist/index.js",
|
|
@@ -34,11 +35,18 @@
|
|
|
34
35
|
"files": [
|
|
35
36
|
"dist",
|
|
36
37
|
"README.md",
|
|
37
|
-
"
|
|
38
|
+
"LICENSE",
|
|
39
|
+
"template/shared",
|
|
40
|
+
"template/node",
|
|
41
|
+
"template/bun"
|
|
38
42
|
],
|
|
39
43
|
"bin": {
|
|
40
44
|
"create-mdsn": "./dist/cli.js"
|
|
41
45
|
},
|
|
46
|
+
"scripts": {
|
|
47
|
+
"prepack": "node ../scripts/sync-package-license.mjs",
|
|
48
|
+
"postpack": "node ../scripts/sync-package-license.mjs --cleanup"
|
|
49
|
+
},
|
|
42
50
|
"exports": {
|
|
43
51
|
".": {
|
|
44
52
|
"types": "./dist/index.d.ts",
|
|
@@ -46,6 +54,6 @@
|
|
|
46
54
|
}
|
|
47
55
|
},
|
|
48
56
|
"dependencies": {
|
|
49
|
-
"@mdsnai/sdk": "0.
|
|
57
|
+
"@mdsnai/sdk": "0.4.0"
|
|
50
58
|
}
|
|
51
59
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# __PROJECT_NAME__
|
|
2
|
+
|
|
3
|
+
This is a minimal MDSN starter for the Bun host.
|
|
4
|
+
|
|
5
|
+
## 30-Second Tour
|
|
6
|
+
|
|
7
|
+
- `app/index.md`
|
|
8
|
+
Defines the page source and interaction.
|
|
9
|
+
- `app/server.ts`
|
|
10
|
+
Owns state and action handlers.
|
|
11
|
+
- `app/client.ts`
|
|
12
|
+
Mounts the browser runtime.
|
|
13
|
+
- `index.mjs`
|
|
14
|
+
Starts the Bun host.
|
|
15
|
+
|
|
16
|
+
## Run It
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
bun install
|
|
20
|
+
bun start
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
This starter is Bun-native, so you can use it without installing Node.
|
|
24
|
+
|
|
25
|
+
Then open [http://127.0.0.1:3000/](http://127.0.0.1:3000/).
|
|
26
|
+
|
|
27
|
+
## First Things To Change
|
|
28
|
+
|
|
29
|
+
1. Edit `app/index.md`
|
|
30
|
+
2. Edit `app/server.ts`
|
|
31
|
+
3. Keep `app/client.ts` as-is, or replace it when you want to own the UI
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
|
|
5
|
+
import { createHost } from "@mdsnai/sdk/server/bun";
|
|
6
|
+
|
|
7
|
+
import { createAppServer } from "./dist/server.js";
|
|
8
|
+
|
|
9
|
+
const port = Number(process.env.PORT || 3000);
|
|
10
|
+
const hostname = process.env.HOST || "127.0.0.1";
|
|
11
|
+
const projectRoot = fileURLToPath(new URL("./", import.meta.url));
|
|
12
|
+
const sourcePath = join(projectRoot, "app", "index.md");
|
|
13
|
+
const assetVersion = Date.now().toString(36);
|
|
14
|
+
|
|
15
|
+
function withVersion(path) {
|
|
16
|
+
return `${path}?v=${assetVersion}`;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const importMap = {
|
|
20
|
+
imports: {
|
|
21
|
+
"@mdsnai/sdk/core": withVersion("/node_modules/@mdsnai/sdk/dist/core/index.js"),
|
|
22
|
+
"@mdsnai/sdk/web": withVersion("/node_modules/@mdsnai/sdk/dist/web/index.js"),
|
|
23
|
+
"@mdsnai/sdk/elements": withVersion("/node_modules/@mdsnai/sdk/dist/elements/index.js"),
|
|
24
|
+
"lit": withVersion("/node_modules/lit/index.js"),
|
|
25
|
+
"lit-html": withVersion("/node_modules/lit-html/lit-html.js"),
|
|
26
|
+
"lit-html/is-server.js": withVersion("/node_modules/lit-html/is-server.js"),
|
|
27
|
+
"lit-element/lit-element.js": withVersion("/node_modules/lit-element/lit-element.js"),
|
|
28
|
+
"@lit/reactive-element": withVersion("/node_modules/@lit/reactive-element/reactive-element.js")
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
function injectEnhancement(html) {
|
|
33
|
+
const enhancement = `
|
|
34
|
+
<script type="importmap">${JSON.stringify(importMap)}</script>
|
|
35
|
+
<script type="module">
|
|
36
|
+
import { mountApp } from "${withVersion("/app/client.js")}";
|
|
37
|
+
mountApp(document, window.fetch.bind(window));
|
|
38
|
+
</script>`;
|
|
39
|
+
|
|
40
|
+
return html.replace("</body>", `${enhancement}\n </body>`);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const source = await readFile(sourcePath, "utf8");
|
|
44
|
+
const mdsn = createAppServer({ source });
|
|
45
|
+
|
|
46
|
+
Bun.serve({
|
|
47
|
+
hostname,
|
|
48
|
+
port,
|
|
49
|
+
fetch: createHost(mdsn, {
|
|
50
|
+
transformHtml: injectEnhancement,
|
|
51
|
+
staticFiles: {
|
|
52
|
+
"/app/client.js": join(projectRoot, "dist", "client.js")
|
|
53
|
+
},
|
|
54
|
+
staticMounts: [
|
|
55
|
+
{
|
|
56
|
+
urlPrefix: "/node_modules/",
|
|
57
|
+
directory: join(projectRoot, "node_modules")
|
|
58
|
+
}
|
|
59
|
+
]
|
|
60
|
+
})
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
console.log(`MDSN starter running at http://${hostname}:${port}/`);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "__PROJECT_NAME__",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"build": "tsc -p tsconfig.json",
|
|
8
|
+
"start": "tsc -p tsconfig.json && bun run index.mjs"
|
|
9
|
+
},
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"@mdsnai/sdk": "__SDK_VERSION__"
|
|
12
|
+
},
|
|
13
|
+
"devDependencies": {
|
|
14
|
+
"@types/node": "^24.6.0",
|
|
15
|
+
"typescript": "^5.9.3"
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -3,7 +3,7 @@ import { readFile } from "node:fs/promises";
|
|
|
3
3
|
import { join } from "node:path";
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { createHost } from "@mdsnai/sdk/server/node";
|
|
7
7
|
|
|
8
8
|
import { createAppServer } from "./dist/server.js";
|
|
9
9
|
|
|
@@ -43,7 +43,7 @@ function injectEnhancement(html) {
|
|
|
43
43
|
const source = await readFile(sourcePath, "utf8");
|
|
44
44
|
const mdsn = createAppServer({ source });
|
|
45
45
|
const server = http.createServer(
|
|
46
|
-
|
|
46
|
+
createHost(mdsn, {
|
|
47
47
|
transformHtml: injectEnhancement,
|
|
48
48
|
staticFiles: {
|
|
49
49
|
"/app/client.js": join(projectRoot, "dist", "client.js")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|