@mastrojs/create-mastro 0.0.2 → 0.0.4
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/README.md +6 -2
- package/index.js +19 -8
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -2,8 +2,12 @@ Create a new [Mastro](https://mastrojs.github.io/) project. Usage:
|
|
|
2
2
|
|
|
3
3
|
Deno:
|
|
4
4
|
|
|
5
|
-
deno run -A npm:@mastrojs/
|
|
5
|
+
deno run -A npm:@mastrojs/create-mastro@latest
|
|
6
6
|
|
|
7
7
|
Node.js
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
pnpm create @mastrojs/mastro@latest
|
|
10
|
+
|
|
11
|
+
Bun
|
|
12
|
+
|
|
13
|
+
bun create @mastrojs/mastro@latest
|
package/index.js
CHANGED
|
@@ -3,10 +3,7 @@
|
|
|
3
3
|
//@ts-check
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* This script initializes an empty Mastro project.
|
|
7
|
-
*
|
|
8
|
-
* Deno: `deno run -A npm:@mastrojs/init@latest`
|
|
9
|
-
* Node.js: `npx @mastrojs/init@latest`
|
|
6
|
+
* This script initializes an empty Mastro project.
|
|
10
7
|
*
|
|
11
8
|
* This is an npm package until JSR has a way to create a "bin" field in the generated package.json
|
|
12
9
|
* See https://github.com/jsr-io/jsr-npm/issues/76
|
|
@@ -20,6 +17,10 @@ import { stdin, stdout } from "node:process";
|
|
|
20
17
|
import { createInterface } from "node:readline/promises";
|
|
21
18
|
import { Readable } from "node:stream";
|
|
22
19
|
|
|
20
|
+
const runtime = typeof Deno === "object"
|
|
21
|
+
? "deno"
|
|
22
|
+
: (process.versions.bun ? "bun" : "node");
|
|
23
|
+
|
|
23
24
|
/**
|
|
24
25
|
* @param {string} path
|
|
25
26
|
* @param {ReadableStream<Uint8Array<ArrayBuffer>>} data
|
|
@@ -28,6 +29,9 @@ import { Readable } from "node:stream";
|
|
|
28
29
|
const writeFile = (path, data) => {
|
|
29
30
|
if (typeof Deno === "object") {
|
|
30
31
|
return Deno.writeFile(path, data);
|
|
32
|
+
} else if (runtime === "bun") {
|
|
33
|
+
// @ts-ignore
|
|
34
|
+
return Bun.write(path, data);
|
|
31
35
|
} else {
|
|
32
36
|
return new Promise((resolve, reject) =>
|
|
33
37
|
// @ts-ignore
|
|
@@ -53,8 +57,7 @@ const execCmd = (cmd) =>
|
|
|
53
57
|
}))
|
|
54
58
|
);
|
|
55
59
|
|
|
56
|
-
const
|
|
57
|
-
const repoName = `template-basic-${isDeno ? "deno" : "node"}`;
|
|
60
|
+
const repoName = `template-basic-${runtime}`;
|
|
58
61
|
const repoUrl = `https://github.com/mastrojs/${repoName}/archive/refs/heads/main.zip`;
|
|
59
62
|
const zipFilePromise = fetch(repoUrl);
|
|
60
63
|
|
|
@@ -83,13 +86,21 @@ if (dir) {
|
|
|
83
86
|
if (unzipSuccess) {
|
|
84
87
|
await fs.rename(outDir, dir);
|
|
85
88
|
|
|
89
|
+
const bunOrPnpm = runtime === "bun" ? "bun" : "pnpm";
|
|
90
|
+
const installInstr = runtime === "deno"
|
|
91
|
+
? ""
|
|
92
|
+
: `\n\nThen install dependencies with: ${bunOrPnpm} install\n`;
|
|
93
|
+
const startInstr = runtime === "deno"
|
|
94
|
+
? "deno task start"
|
|
95
|
+
: `${bunOrPnpm} run start`;
|
|
96
|
+
|
|
86
97
|
const codeStyle = "color: blue";
|
|
87
98
|
console.log(
|
|
88
99
|
`
|
|
89
100
|
Success!
|
|
90
101
|
|
|
91
|
-
Enter the newly created folder with: %ccd ${dir}${
|
|
92
|
-
%cThen start the dev server with: %c${
|
|
102
|
+
Enter the newly created folder with: %ccd ${dir}${installInstr}
|
|
103
|
+
%cThen start the dev server with: %c${startInstr}`,
|
|
93
104
|
codeStyle,
|
|
94
105
|
"",
|
|
95
106
|
codeStyle,
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastrojs/create-mastro",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
|
-
"publish": "deno check && npm publish --access public"
|
|
6
|
+
"npm-publish": "deno check && npm publish --access public"
|
|
7
7
|
},
|
|
8
8
|
"bin": {
|
|
9
9
|
"create-mastro": "index.js"
|