create-glion 0.0.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 +38 -0
- package/dist/index.js +116 -0
- package/dist/index.js.map +1 -0
- package/package.json +59 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Rethink Health
|
|
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
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# create-glion
|
|
2
|
+
|
|
3
|
+
Scaffold a new Glion app from an example in [`rethinkhealth/glion`](https://github.com/rethinkhealth/glion).
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# Interactive
|
|
9
|
+
pnpm create glion
|
|
10
|
+
npm create glion
|
|
11
|
+
yarn create glion
|
|
12
|
+
bun create glion
|
|
13
|
+
|
|
14
|
+
# Non-interactive
|
|
15
|
+
pnpm create glion my-app --example mllp-server
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Options
|
|
19
|
+
|
|
20
|
+
| Flag | Description |
|
|
21
|
+
| ---------------------- | -------------------------------------------------------- |
|
|
22
|
+
| `[dir]` (positional) | Target directory. Prompts when omitted. |
|
|
23
|
+
| `-e, --example <name>` | Example to clone from `examples/`. Prompts when omitted. |
|
|
24
|
+
| `-h, --help` | Print usage and exit. |
|
|
25
|
+
|
|
26
|
+
## Examples
|
|
27
|
+
|
|
28
|
+
| Name | Description |
|
|
29
|
+
| ----------------- | -------------------------------------------------------------- |
|
|
30
|
+
| `mllp-server` | HL7v2 MLLP server with route handlers (Node.js). |
|
|
31
|
+
| `mllp-server-bun` | HL7v2 MLLP server with route handlers (Bun). |
|
|
32
|
+
| `mllp-client` | MLLP client sending sample messages — companion to the server. |
|
|
33
|
+
|
|
34
|
+
Each example is fetched from `github:rethinkhealth/glion/examples/<name>` via [`giget`](https://github.com/unjs/giget).
|
|
35
|
+
|
|
36
|
+
## License
|
|
37
|
+
|
|
38
|
+
MIT © Glion contributors
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
|
+
import { resolve } from "node:path";
|
|
4
|
+
import { parseArgs } from "node:util";
|
|
5
|
+
import * as p from "@clack/prompts";
|
|
6
|
+
import { downloadTemplate } from "giget";
|
|
7
|
+
//#region src/index.ts
|
|
8
|
+
const REPO = "github:rethinkhealth/glion";
|
|
9
|
+
const EXAMPLES = [
|
|
10
|
+
{
|
|
11
|
+
hint: "HL7v2 MLLP server with route handlers (Node.js)",
|
|
12
|
+
label: "mllp-server",
|
|
13
|
+
value: "mllp-server"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
hint: "HL7v2 MLLP server with route handlers (Bun)",
|
|
17
|
+
label: "mllp-server-bun",
|
|
18
|
+
value: "mllp-server-bun"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
hint: "MLLP client sending sample messages",
|
|
22
|
+
label: "mllp-client",
|
|
23
|
+
value: "mllp-client"
|
|
24
|
+
}
|
|
25
|
+
];
|
|
26
|
+
const HELP = `Usage: create-glion [dir] [--example <name>]
|
|
27
|
+
|
|
28
|
+
Options:
|
|
29
|
+
-e, --example <name> Example to clone from examples/
|
|
30
|
+
-h, --help Show this message
|
|
31
|
+
|
|
32
|
+
Examples:
|
|
33
|
+
${EXAMPLES.map((e) => ` ${e.value.padEnd(18)} ${e.hint}`).join("\n")}
|
|
34
|
+
`;
|
|
35
|
+
function isExampleId(value) {
|
|
36
|
+
return EXAMPLES.some((e) => e.value === value);
|
|
37
|
+
}
|
|
38
|
+
function abort(message = "Aborted.") {
|
|
39
|
+
p.cancel(message);
|
|
40
|
+
process.exit(0);
|
|
41
|
+
}
|
|
42
|
+
async function run() {
|
|
43
|
+
const { values, positionals } = parseArgs({
|
|
44
|
+
allowPositionals: true,
|
|
45
|
+
args: process.argv.slice(2),
|
|
46
|
+
options: {
|
|
47
|
+
example: {
|
|
48
|
+
short: "e",
|
|
49
|
+
type: "string"
|
|
50
|
+
},
|
|
51
|
+
help: {
|
|
52
|
+
short: "h",
|
|
53
|
+
type: "boolean"
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
if (values.help) {
|
|
58
|
+
process.stdout.write(`${HELP}\n`);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
p.intro("create-glion");
|
|
62
|
+
let dir = positionals[0];
|
|
63
|
+
if (!dir) {
|
|
64
|
+
const answer = await p.text({
|
|
65
|
+
message: "Where should we scaffold your project?",
|
|
66
|
+
placeholder: "./my-glion-app",
|
|
67
|
+
validate: (value) => value.trim().length === 0 ? "Please enter a directory." : void 0
|
|
68
|
+
});
|
|
69
|
+
if (p.isCancel(answer)) abort();
|
|
70
|
+
dir = answer;
|
|
71
|
+
}
|
|
72
|
+
const target = resolve(process.cwd(), dir);
|
|
73
|
+
if (existsSync(target)) {
|
|
74
|
+
const proceed = await p.confirm({
|
|
75
|
+
initialValue: false,
|
|
76
|
+
message: `${target} already exists. Continue and overwrite?`
|
|
77
|
+
});
|
|
78
|
+
if (p.isCancel(proceed) || !proceed) abort();
|
|
79
|
+
}
|
|
80
|
+
let example = values.example;
|
|
81
|
+
if (example && !isExampleId(example)) {
|
|
82
|
+
p.cancel(`Unknown example: ${example}. Available: ${EXAMPLES.map((e) => e.value).join(", ")}`);
|
|
83
|
+
process.exit(1);
|
|
84
|
+
}
|
|
85
|
+
if (!example) {
|
|
86
|
+
const choice = await p.select({
|
|
87
|
+
message: "Choose an example",
|
|
88
|
+
options: EXAMPLES.map((e) => ({
|
|
89
|
+
hint: e.hint,
|
|
90
|
+
label: e.label,
|
|
91
|
+
value: e.value
|
|
92
|
+
}))
|
|
93
|
+
});
|
|
94
|
+
if (p.isCancel(choice)) abort();
|
|
95
|
+
example = choice;
|
|
96
|
+
}
|
|
97
|
+
const spinner = p.spinner();
|
|
98
|
+
spinner.start(`Downloading example: ${example}`);
|
|
99
|
+
await downloadTemplate(`${REPO}/examples/${example}`, {
|
|
100
|
+
dir: target,
|
|
101
|
+
force: true
|
|
102
|
+
});
|
|
103
|
+
spinner.stop(`Scaffolded ${example} → ${target}`);
|
|
104
|
+
p.note(`cd ${dir}\npnpm install\npnpm dev`, "Next steps");
|
|
105
|
+
p.outro("Happy hacking!");
|
|
106
|
+
}
|
|
107
|
+
try {
|
|
108
|
+
await run();
|
|
109
|
+
} catch (error) {
|
|
110
|
+
p.cancel(error instanceof Error ? error.message : String(error));
|
|
111
|
+
process.exit(1);
|
|
112
|
+
}
|
|
113
|
+
//#endregion
|
|
114
|
+
export {};
|
|
115
|
+
|
|
116
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { existsSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\nimport { parseArgs } from \"node:util\";\n\nimport * as p from \"@clack/prompts\";\nimport { downloadTemplate } from \"giget\";\n\nconst REPO = \"github:rethinkhealth/glion\";\n\nconst EXAMPLES = [\n {\n hint: \"HL7v2 MLLP server with route handlers (Node.js)\",\n label: \"mllp-server\",\n value: \"mllp-server\",\n },\n {\n hint: \"HL7v2 MLLP server with route handlers (Bun)\",\n label: \"mllp-server-bun\",\n value: \"mllp-server-bun\",\n },\n {\n hint: \"MLLP client sending sample messages\",\n label: \"mllp-client\",\n value: \"mllp-client\",\n },\n] as const;\n\ntype ExampleId = (typeof EXAMPLES)[number][\"value\"];\n\nconst HELP = `Usage: create-glion [dir] [--example <name>]\n\nOptions:\n -e, --example <name> Example to clone from examples/\n -h, --help Show this message\n\nExamples:\n${EXAMPLES.map((e) => ` ${e.value.padEnd(18)} ${e.hint}`).join(\"\\n\")}\n`;\n\nfunction isExampleId(value: string): value is ExampleId {\n return EXAMPLES.some((e) => e.value === value);\n}\n\nfunction abort(message = \"Aborted.\"): never {\n p.cancel(message);\n process.exit(0);\n}\n\nasync function run(): Promise<void> {\n const { values, positionals } = parseArgs({\n allowPositionals: true,\n args: process.argv.slice(2),\n options: {\n example: { short: \"e\", type: \"string\" },\n help: { short: \"h\", type: \"boolean\" },\n },\n });\n\n if (values.help) {\n process.stdout.write(`${HELP}\\n`);\n return;\n }\n\n p.intro(\"create-glion\");\n\n let dir = positionals[0];\n if (!dir) {\n const answer = await p.text({\n message: \"Where should we scaffold your project?\",\n placeholder: \"./my-glion-app\",\n validate: (value) =>\n value.trim().length === 0 ? \"Please enter a directory.\" : undefined,\n });\n if (p.isCancel(answer)) {\n abort();\n }\n dir = answer;\n }\n\n const target = resolve(process.cwd(), dir);\n\n if (existsSync(target)) {\n const proceed = await p.confirm({\n initialValue: false,\n message: `${target} already exists. Continue and overwrite?`,\n });\n if (p.isCancel(proceed) || !proceed) {\n abort();\n }\n }\n\n let example = values.example;\n if (example && !isExampleId(example)) {\n p.cancel(\n `Unknown example: ${example}. Available: ${EXAMPLES.map((e) => e.value).join(\", \")}`\n );\n process.exit(1);\n }\n\n if (!example) {\n const choice = await p.select({\n message: \"Choose an example\",\n options: EXAMPLES.map((e) => ({\n hint: e.hint,\n label: e.label,\n value: e.value,\n })),\n });\n if (p.isCancel(choice)) {\n abort();\n }\n example = choice;\n }\n\n const spinner = p.spinner();\n spinner.start(`Downloading example: ${example}`);\n await downloadTemplate(`${REPO}/examples/${example}`, {\n dir: target,\n force: true,\n });\n spinner.stop(`Scaffolded ${example} → ${target}`);\n\n p.note(`cd ${dir}\\npnpm install\\npnpm dev`, \"Next steps\");\n p.outro(\"Happy hacking!\");\n}\n\ntry {\n await run();\n} catch (error: unknown) {\n p.cancel(error instanceof Error ? error.message : String(error));\n process.exit(1);\n}\n"],"mappings":";;;;;;;AAQA,MAAM,OAAO;AAEb,MAAM,WAAW;CACf;EACE,MAAM;EACN,OAAO;EACP,OAAO;EACR;CACD;EACE,MAAM;EACN,OAAO;EACP,OAAO;EACR;CACD;EACE,MAAM;EACN,OAAO;EACP,OAAO;EACR;CACF;AAID,MAAM,OAAO;;;;;;;EAOX,SAAS,KAAK,MAAM,KAAK,EAAE,MAAM,OAAO,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,KAAK,KAAK,CAAC;;AAGtE,SAAS,YAAY,OAAmC;AACtD,QAAO,SAAS,MAAM,MAAM,EAAE,UAAU,MAAM;;AAGhD,SAAS,MAAM,UAAU,YAAmB;AAC1C,GAAE,OAAO,QAAQ;AACjB,SAAQ,KAAK,EAAE;;AAGjB,eAAe,MAAqB;CAClC,MAAM,EAAE,QAAQ,gBAA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B,GAAG,KAAK,YAAY,WAAW;EACpD,KAAK;EACL,OAAO;EACR,CAAC;AACF,SAAQ,KAAK,cAAc,QAAQ,KAAK,SAAS;AAEjD,GAAE,KAAK,MAAM,IAAI,2BAA2B,aAAa;AACzD,GAAE,MAAM,iBAAiB;;AAG3B,IAAI;AACF,OAAM,KAAK;SACJ,OAAgB;AACvB,GAAE,OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM,CAAC;AAChE,SAAQ,KAAK,EAAE"}
|
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "create-glion",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "Scaffold a new Glion app from an example.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"create",
|
|
7
|
+
"glion",
|
|
8
|
+
"hl7",
|
|
9
|
+
"hl7v2",
|
|
10
|
+
"mllp",
|
|
11
|
+
"scaffold",
|
|
12
|
+
"starter",
|
|
13
|
+
"template"
|
|
14
|
+
],
|
|
15
|
+
"homepage": "https://glion.dev",
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"author": {
|
|
18
|
+
"name": "Melek Somai",
|
|
19
|
+
"email": "melek@rethinkhealth.io"
|
|
20
|
+
},
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "git+https://github.com/rethinkhealth/glion.git",
|
|
24
|
+
"directory": "packages/create-glion"
|
|
25
|
+
},
|
|
26
|
+
"bin": {
|
|
27
|
+
"create-glion": "./dist/index.js"
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"dist"
|
|
31
|
+
],
|
|
32
|
+
"type": "module",
|
|
33
|
+
"publishConfig": {
|
|
34
|
+
"access": "public"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@clack/prompts": "0.11.0",
|
|
38
|
+
"giget": "2.0.0"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@types/node": "25.6.0",
|
|
42
|
+
"publint": "0.3.18",
|
|
43
|
+
"tsdown": "0.21.10",
|
|
44
|
+
"typescript": "6.0.3",
|
|
45
|
+
"vitest": "4.1.5",
|
|
46
|
+
"@glion/testing": "0.16.0",
|
|
47
|
+
"@glion/tsconfig": "0.16.0"
|
|
48
|
+
},
|
|
49
|
+
"engines": {
|
|
50
|
+
"node": ">=20"
|
|
51
|
+
},
|
|
52
|
+
"scripts": {
|
|
53
|
+
"build": "tsdown",
|
|
54
|
+
"check-types": "tsc --noEmit",
|
|
55
|
+
"test": "vitest run --passWithNoTests",
|
|
56
|
+
"test:watch": "vitest",
|
|
57
|
+
"publint": "publint --strict"
|
|
58
|
+
}
|
|
59
|
+
}
|