create-cookbook 1.0.0-beta.5 → 1.0.0-beta.51

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 (2) hide show
  1. package/index.mjs +201 -192
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -7,7 +7,7 @@ import { Readable } from "node:stream";
7
7
  import { finished } from "node:stream/promises";
8
8
  import { execFileSync } from "node:child_process";
9
9
  import { mkdirSync, existsSync, createWriteStream, rmSync } from "node:fs";
10
- import { remove } from "fs-extra";
10
+ import { remove, move } from "fs-extra";
11
11
  import consola from "consola";
12
12
  import gradient from "gradient-string";
13
13
  import compressing from "compressing";
@@ -16,208 +16,217 @@ const colorLong = gradient(["cyan", "green"]);
16
16
  const color = gradient(["cyan", "#2d9b87"]);
17
17
 
18
18
  (async () => {
19
- const args = process.argv.slice(2);
20
- let version = "latest";
21
- // biome-ignore lint/complexity/useOptionalChain: <explanation>
22
- if (args[0] && args[0].startsWith("--version=")) {
23
- version = args[0].slice(10);
19
+ const args = process.argv.slice(2);
20
+ let version = "latest";
21
+ let installPath = undefined;
22
+ for (const arg of args) {
23
+ if (arg.startsWith("--version=")) {
24
+ version = arg.slice(10);
25
+ } else {
26
+ installPath = arg;
24
27
  }
25
- const workspace = process.platform === "win32" ? join(process.env.USERPROFILE, ".cookbook") : join(process.env.HOME, ".cookbook");
26
- const tempspace = process.platform === "win32" ? join(process.env.USERPROFILE, ".cookbook", ".temp") : join(process.env.HOME, ".cookbook", ".temp");
27
- if (!existsSync(workspace)) mkdirSync(workspace);
28
- if (!existsSync(tempspace)) mkdirSync(tempspace);
28
+ }
29
29
 
30
- const uiName = "@milkio/cookbook-ui";
31
- const cookbookName = `@milkio/cookbook-${process.platform}-${os.arch()}`;
32
- let uiPackageInfo;
33
- let cookbookPackageInfo;
34
- console.log("");
35
- for (const mirror of ["https://registry.npmjs.org/", "https://registry.npmmirror.com/", "https://mirrors.cloud.tencent.com/npm/", "https://cdn.jsdelivr.net/npm/"]) {
36
- try {
37
- consola.start(color(`[1/2] Checking (${mirror}${uiName})..`));
38
- const controller = new AbortController();
39
- const timeout = setTimeout(() => controller.abort(), 8000);
40
- const response = await fetch(`${mirror}${uiName}`, {
41
- signal: controller.signal
42
- });
43
- clearTimeout(timeout);
44
- if (response.status !== 200) continue;
45
- const json = await response.json();
46
- if (json.name !== uiName) continue;
47
- uiPackageInfo = {
48
- mirror,
49
- json,
50
- };
51
- break;
52
- } catch (error) {
53
- // biome-ignore lint/correctness/noUnnecessaryContinue: <explanation>
54
- continue;
55
- }
56
- }
57
- if (!uiPackageInfo) {
58
- consola.error(color("Network connection failed!"));
59
- exit(1);
60
- }
61
- for (const mirror of ["https://registry.npmjs.org/", "https://registry.npmmirror.com/", "https://mirrors.cloud.tencent.com/npm/", "https://cdn.jsdelivr.net/npm/"]) {
62
- try {
63
- consola.start(color(`[2/2] Checking (${mirror}${cookbookName})..`));
64
- const controller = new AbortController();
65
- const timeout = setTimeout(() => controller.abort(), 8000);
66
- const response = await fetch(`${mirror}${cookbookName}`, {
67
- signal: controller.signal
68
- });
69
- clearTimeout(timeout);
70
- if (response.status !== 200) continue;
71
- const json = await response.json();
72
- if (json.name !== cookbookName) continue;
73
- cookbookPackageInfo = {
74
- mirror,
75
- json,
76
- };
77
- break;
78
- } catch (error) {
79
- // biome-ignore lint/correctness/noUnnecessaryContinue: <explanation>
80
- continue;
81
- }
30
+ const workspace = process.platform === "win32" ? join(process.env.USERPROFILE, ".cookbook") : join(process.env.HOME, ".cookbook");
31
+ const tempspace = process.platform === "win32" ? join(process.env.USERPROFILE, ".cookbook", ".temp") : join(process.env.HOME, ".cookbook", ".temp");
32
+ if (!existsSync(workspace)) mkdirSync(workspace);
33
+ if (!existsSync(tempspace)) mkdirSync(tempspace);
34
+
35
+ const uiName = "@milkio/cookbook-ui";
36
+ const cookbookName = `@milkio/cookbook-${process.platform}-${os.arch()}`;
37
+ let uiPackageInfo;
38
+ let cookbookPackageInfo;
39
+ console.log("");
40
+ for (const mirror of ["https://registry.npmjs.org/", "https://registry.npmmirror.com/", "https://mirrors.cloud.tencent.com/npm/", "https://cdn.jsdelivr.net/npm/"]) {
41
+ try {
42
+ consola.start(color(`[1/2] Checking (${mirror}${uiName})..`));
43
+ const controller = new AbortController();
44
+ const timeout = setTimeout(() => controller.abort(), 8000);
45
+ const response = await fetch(`${mirror}${uiName}`, {
46
+ signal: controller.signal,
47
+ });
48
+ clearTimeout(timeout);
49
+ if (response.status !== 200) continue;
50
+ const json = await response.json();
51
+ if (json.name !== uiName) continue;
52
+ uiPackageInfo = {
53
+ mirror,
54
+ json,
55
+ };
56
+ break;
57
+ } catch (error) {
58
+ // biome-ignore lint/correctness/noUnnecessaryContinue: <explanation>
59
+ continue;
82
60
  }
83
- if (!cookbookPackageInfo) {
84
- consola.error(color("Network connection failed!"));
85
- exit(1);
61
+ }
62
+ if (!uiPackageInfo) {
63
+ consola.error(color("Network connection failed!"));
64
+ exit(1);
65
+ }
66
+ for (const mirror of ["https://registry.npmjs.org/", "https://registry.npmmirror.com/", "https://mirrors.cloud.tencent.com/npm/", "https://cdn.jsdelivr.net/npm/"]) {
67
+ try {
68
+ consola.start(color(`[2/2] Checking (${mirror}${cookbookName})..`));
69
+ const controller = new AbortController();
70
+ const timeout = setTimeout(() => controller.abort(), 8000);
71
+ const response = await fetch(`${mirror}${cookbookName}`, {
72
+ signal: controller.signal,
73
+ });
74
+ clearTimeout(timeout);
75
+ if (response.status !== 200) continue;
76
+ const json = await response.json();
77
+ if (json.name !== cookbookName) continue;
78
+ cookbookPackageInfo = {
79
+ mirror,
80
+ json,
81
+ };
82
+ break;
83
+ } catch (error) {
84
+ // biome-ignore lint/correctness/noUnnecessaryContinue: <explanation>
85
+ continue;
86
86
  }
87
+ }
88
+ if (!cookbookPackageInfo) {
89
+ consola.error(color("Network connection failed!"));
90
+ exit(1);
91
+ }
87
92
 
88
- const uiUrl = `${cookbookPackageInfo.mirror}${uiName}/-/cookbook-ui-${version === 'latest' ? uiPackageInfo.json["dist-tags"].latest : version}.tgz`;
89
- consola.start(uiUrl);
90
- consola.start(color(`[1/2] Downloading Cookbook UI (${uiUrl})..`));
91
- await utils.downloadFile(uiUrl, tempspace, "ui.tgz");
92
- consola.success(color("[1/2] Downloaded!"));
93
- const uiExtractPromise = ((async () => {
94
- if (!existsSync(join(tempspace, "ui"))) mkdirSync(join(tempspace, "ui"))
95
- await compressing.tgz.uncompress(join(tempspace, "ui.tgz"), join(tempspace, "ui"));
96
- }))();
93
+ // const uiUrl = `${cookbookPackageInfo.mirror}${uiName}/-/cookbook-ui-${version === "latest" ? uiPackageInfo.json["dist-tags"].latest : version}.tgz`;
94
+ // consola.start(uiUrl);
95
+ // consola.start(color(`[1/2] Downloading Cookbook UI (${uiUrl})..`));
96
+ // await utils.downloadFile(uiUrl, tempspace, "ui.tgz");
97
+ // consola.success(color("[1/2] Downloaded!"));
98
+ // const uiExtractPromise = (async () => {
99
+ // if (!existsSync(join(tempspace, "ui"))) mkdirSync(join(tempspace, "ui"));
100
+ // await compressing.tgz.uncompress(join(tempspace, "ui.tgz"), join(tempspace, "ui"));
101
+ // })();
97
102
 
98
- const cookbookUrl = `${cookbookPackageInfo.mirror}${cookbookName}/-/cookbook-${process.platform}-${os.arch()}-${version === 'latest' ? cookbookPackageInfo.json["dist-tags"].latest : version}.tgz`;
99
- consola.start(cookbookUrl);
100
- consola.start(color(`[2/2] Downloading Cookbook Core (${cookbookUrl})..`));
101
- await utils.downloadFile(cookbookUrl, tempspace, "cookbook.tgz");
102
- consola.success(color("[2/2] Downloaded!"));
103
- const cookbookExtractPromise = ((async () => {
104
- await compressing.tgz.uncompress(join(tempspace, "cookbook.tgz"), tempspace);
105
- }))();
103
+ const cookbookUrl = `${cookbookPackageInfo.mirror}${cookbookName}/-/cookbook-${process.platform}-${os.arch()}-${version === "latest" ? cookbookPackageInfo.json["dist-tags"].latest : version}.tgz`;
104
+ consola.start(cookbookUrl);
105
+ consola.start(color(`[2/2] Downloading Cookbook Core (${cookbookUrl})..`));
106
+ await utils.downloadFile(cookbookUrl, tempspace, "cookbook.tgz");
107
+ consola.success(color("[2/2] Downloaded!"));
108
+ const cookbookExtractPromise = (async () => {
109
+ await compressing.tgz.uncompress(join(tempspace, "cookbook.tgz"), tempspace);
110
+ })();
106
111
 
107
- consola.start(color("[1/2] Extracting.."));
108
- await Promise.all([uiExtractPromise, cookbookExtractPromise]);
109
- consola.success(color("[1/2] Extracted!"));
112
+ // consola.start(color("[1/2] Extracting.."));
113
+ // await Promise.all([uiExtractPromise, cookbookExtractPromise]);
114
+ // consola.success(color("[1/2] Extracted!"));
110
115
 
111
- consola.success(color("[2/2] Installing.."));
112
- await utils.mvToPathAndInstall(join(tempspace, "package"), process.platform === "win32" ? "co.exe" : "co", tempspace);
113
- await utils.mvUIDir(join(tempspace, "ui", "package"));
114
- await utils.tempspaceClean(tempspace);
115
- consola.success(color("[2/2] Installed!"));
116
+ consola.success(color("[2/2] Installing.."));
117
+ await utils.mvToPathAndInstall(installPath, join(tempspace, "package"), process.platform === "win32" ? "co.exe" : "co");
118
+ // await utils.mvUIDir(join(tempspace, "ui", "package"));
119
+ await utils.tempspaceClean(tempspace);
120
+ consola.success(color("[2/2] Installed!"));
116
121
 
117
- console.log("");
118
- consola.info(color("Try run: co version"));
119
- consola.info(colorLong("* If you find that the co command does not exist, try restarting your Terminal or System"));
122
+ console.log("");
123
+ consola.info(color("Try run: co version"));
124
+ consola.info(colorLong("* If you find that the co command does not exist, try restarting your Terminal or System"));
120
125
  })();
121
126
 
122
127
  const utils = {
123
- downloadFile: async (url, workspace, filename) => {
124
- const res = await fetch(url);
125
- if (existsSync(join(workspace, filename))) await remove(join(workspace, filename));
126
- const destination = join(workspace, filename);
127
- const fileStream = createWriteStream(destination, { flags: "wx" });
128
- await finished(Readable.fromWeb(res.body).pipe(fileStream));
129
- },
130
- mvUIDir: async (tempspace) => {
131
- if (!existsSync(process.env.HOME || process.env.USERPROFILE, ".cookbook")) mkdirSync(join(process.env.HOME || process.env.USERPROFILE, ".cookbook"));
132
- if (process.platform === "win32") {
133
- if (existsSync(join(process.env.USERPROFILE, ".cookbook", 'ui'))) await utils.executePowershell(`Remove-Item -Recurse -Force "${join(process.env.USERPROFILE, ".cookbook", 'ui')}";`);
134
- await utils.executePowershell(`Move-Item -Path "${join(tempspace)}" -Destination "${join(process.env.USERPROFILE, ".cookbook", 'ui')}" -Force;`);
135
- return;
136
- }
137
- if (process.platform === "linux") {
138
- if (existsSync(join(process.env.HOME, ".cookbook", 'ui'))) await utils.executeBash(`rm -rf "${join(process.env.HOME, ".cookbook", 'ui')}";`);
139
- await utils.executeBash(`mv "${join(tempspace)}" "${join(process.env.HOME, ".cookbook", 'ui')}"`);
140
- }
141
- if (process.platform === "darwin") {
142
- if (existsSync(join(process.env.HOME, ".cookbook", 'ui'))) await utils.executeBash(`rm -rf "${join(process.env.HOME, ".cookbook", 'ui')}";`);
143
- await utils.executeBash(`mv "${join(tempspace)}" "${join(process.env.HOME, ".cookbook", 'ui')}"`);
144
- }
145
- },
146
- tempspaceClean: async (tempspace) => {
147
- if (process.platform === "win32") {
148
- if (existsSync(join(tempspace))) await utils.executePowershell(`Remove-Item -Recurse -Force "${join(tempspace)}";`);
149
- return;
150
- }
151
- if (process.platform === "linux") {
152
- if (existsSync(join(tempspace))) await utils.executeBash(`rm -rf "${join(tempspace)}"`);
153
- }
154
- if (process.platform === "darwin") {
155
- if (existsSync(join(tempspace))) await utils.executeBash(`rm -rf "${join(tempspace)}"`);
156
- }
157
- },
158
- mvToPathAndInstall: async (workspace, filename, tempspace) => {
159
- if (process.platform === "win32") {
160
- await new Promise((resolve) => setTimeout(resolve, 500));
161
- if (!(process.env.PATH.includes(`${join(process.env.USERPROFILE, ".cookbook")};`) || process.env.PATH.includes(`;${join(process.env.USERPROFILE, ".cookbook")}`) || process.env.PATH === `${join(process.env.USERPROFILE, ".cookbook")}`)) {
162
- await utils.executePowershell(`[System.Environment]::SetEnvironmentVariable("PATH", [System.Environment]::GetEnvironmentVariable("PATH", "User") + ";${join(process.env.USERPROFILE, ".cookbook")}", "User");`);
163
- }
164
- if (!existsSync(process.env.USERPROFILE, ".cookbook")) mkdirSync(process.env.USERPROFILE, ".cookbook");
165
- if (existsSync(join(process.env.USERPROFILE, ".cookbook", filename))) rmSync(join(process.env.USERPROFILE, ".cookbook", filename));
166
- await utils.executePowershell(`Move-Item -Path "${join(workspace, filename)}" -Destination "${join(process.env.USERPROFILE, ".cookbook")}";`);
167
- return;
168
- }
169
- if (process.platform === "linux") {
170
- const paths = [join(process.env.HOME, ".bin"), "/usr/bin/", "/usr/sbin"];
171
- let pathChecked = "";
172
- for (const path of paths) {
173
- if (process.env.PATH.includes(`${path}:`) || process.env.PATH.includes(`:${path}`) || process.env.PATH === `${path}`) {
174
- pathChecked = path;
175
- break;
176
- }
177
- }
178
- if (!pathChecked) {
179
- consola.error(color("No path found!"));
180
- exit(0);
181
- }
182
- if (!existsSync(pathChecked)) mkdirSync(pathChecked);
183
- if (existsSync(join(pathChecked, filename))) {
184
- if (pathChecked.startsWith("/home")) await utils.executeBash(`rm -f ${join(pathChecked, filename)}`);
185
- else await utils.executeBash(`rm -f ${join(pathChecked, filename)}`);
186
- }
187
- if (pathChecked.startsWith("/home")) await utils.executeBash(`mv ${join(workspace, filename)} ${pathChecked} && chmod +x ${join(pathChecked, filename)}`);
188
- else await utils.executeBash(`mv ${join(workspace, filename)} ${pathChecked} && chmod +x ${join(pathChecked, filename)}`);
128
+ downloadFile: async (url, workspace, filename) => {
129
+ const res = await fetch(url);
130
+ if (existsSync(join(workspace, filename))) await remove(join(workspace, filename));
131
+ const destination = join(workspace, filename);
132
+ const fileStream = createWriteStream(destination, { flags: "wx" });
133
+ await finished(Readable.fromWeb(res.body).pipe(fileStream));
134
+ },
135
+ mvUIDir: async (tempspace) => {
136
+ if (!existsSync(process.env.HOME || process.env.USERPROFILE, ".cookbook")) mkdirSync(join(process.env.HOME || process.env.USERPROFILE, ".cookbook"));
137
+ if (process.platform === "win32") {
138
+ if (existsSync(join(process.env.USERPROFILE, ".cookbook", "ui"))) await utils.executePowershell(`Remove-Item -Recurse -Force "${join(process.env.USERPROFILE, ".cookbook", "ui")}";`);
139
+ await utils.executePowershell(`Move-Item -Path "${join(tempspace)}" -Destination "${join(process.env.USERPROFILE, ".cookbook", "ui")}" -Force;`);
140
+ return;
141
+ }
142
+ if (process.platform === "linux") {
143
+ if (existsSync(join(process.env.HOME, ".cookbook", "ui"))) await utils.executeBash(`rm -rf "${join(process.env.HOME, ".cookbook", "ui")}";`);
144
+ await utils.executeBash(`mv "${join(tempspace)}" "${join(process.env.HOME, ".cookbook", "ui")}"`);
145
+ }
146
+ if (process.platform === "darwin") {
147
+ if (existsSync(join(process.env.HOME, ".cookbook", "ui"))) await utils.executeBash(`rm -rf "${join(process.env.HOME, ".cookbook", "ui")}";`);
148
+ await utils.executeBash(`mv "${join(tempspace)}" "${join(process.env.HOME, ".cookbook", "ui")}"`);
149
+ }
150
+ },
151
+ tempspaceClean: async (tempspace) => {
152
+ if (process.platform === "win32") {
153
+ if (existsSync(join(tempspace))) await utils.executePowershell(`Remove-Item -Recurse -Force "${join(tempspace)}";`);
154
+ return;
155
+ }
156
+ if (process.platform === "linux") {
157
+ if (existsSync(join(tempspace))) await utils.executeBash(`rm -rf "${join(tempspace)}"`);
158
+ }
159
+ if (process.platform === "darwin") {
160
+ if (existsSync(join(tempspace))) await utils.executeBash(`rm -rf "${join(tempspace)}"`);
161
+ }
162
+ },
163
+ mvToPathAndInstall: async (installPath, workspace, filename) => {
164
+ if (installPath) {
165
+ if (!existsSync(installPath)) mkdirSync(installPath, { recursive: true });
166
+ await move(join(workspace, filename), join(installPath, filename), { overwrite: true });
167
+ return;
168
+ }
169
+ if (process.platform === "win32") {
170
+ await new Promise((resolve) => setTimeout(resolve, 500));
171
+ if (!(process.env.PATH.includes(`${join(process.env.USERPROFILE, ".cookbook")};`) || process.env.PATH.includes(`;${join(process.env.USERPROFILE, ".cookbook")}`) || process.env.PATH === `${join(process.env.USERPROFILE, ".cookbook")}`)) {
172
+ await utils.executePowershell(`[System.Environment]::SetEnvironmentVariable("PATH", [System.Environment]::GetEnvironmentVariable("PATH", "User") + ";${join(process.env.USERPROFILE, ".cookbook")}", "User");`);
173
+ }
174
+ if (!existsSync(process.env.USERPROFILE, ".cookbook")) mkdirSync(process.env.USERPROFILE, ".cookbook");
175
+ if (existsSync(join(process.env.USERPROFILE, ".cookbook", filename))) rmSync(join(process.env.USERPROFILE, ".cookbook", filename));
176
+ await utils.executePowershell(`Move-Item -Path "${join(workspace, filename)}" -Destination "${join(process.env.USERPROFILE, ".cookbook")}";`);
177
+ return;
178
+ }
179
+ if (process.platform === "linux") {
180
+ const paths = [join(process.env.HOME, ".bin"), "/usr/bin/", "/usr/sbin"];
181
+ let pathChecked = "";
182
+ for (const path of paths) {
183
+ if (process.env.PATH.includes(`${path}:`) || process.env.PATH.includes(`:${path}`) || process.env.PATH === `${path}`) {
184
+ pathChecked = path;
185
+ break;
189
186
  }
190
- if (process.platform === "darwin") {
191
- const paths = [join(process.env.HOME, "bin"), join(process.env.HOME, ".bin"), join(process.env.HOME, ".local", "bin"), "/usr/local/bin"];
192
- let pathChecked = "";
193
- for (const path of paths) {
194
- if (process.env.PATH.includes(`${path}:`) || process.env.PATH.includes(`:${path}`) || process.env.PATH === `${path}`) {
195
- pathChecked = path;
196
- break;
197
- }
198
- }
199
- if (!pathChecked) {
200
- consola.error(color("No path found!"));
201
- exit(0);
202
- }
203
- if (!existsSync(pathChecked)) mkdirSync(pathChecked);
204
- if (existsSync(join(pathChecked, filename))) {
205
- if (pathChecked.startsWith("/Users")) await utils.executeBash(`rm -f ${join(pathChecked, filename)}`);
206
- else await utils.executeBash(`rm -f ${join(pathChecked, filename)}`);
207
- }
208
- if (pathChecked.startsWith("/Users")) await utils.executeBash(`mv ${join(workspace, filename)} ${pathChecked} && chmod +x ${join(pathChecked, filename)}`);
209
- else await utils.executeBash(`mv ${join(workspace, filename)} ${pathChecked} && chmod +x ${join(pathChecked, filename)}`);
187
+ }
188
+ if (!pathChecked) {
189
+ consola.error(color("No path found!"));
190
+ exit(0);
191
+ }
192
+ if (!existsSync(pathChecked)) mkdirSync(pathChecked);
193
+ if (existsSync(join(pathChecked, filename))) {
194
+ if (pathChecked.startsWith("/home")) await utils.executeBash(`rm -f ${join(pathChecked, filename)}`);
195
+ else await utils.executeBash(`rm -f ${join(pathChecked, filename)}`);
196
+ }
197
+ if (pathChecked.startsWith("/home")) await utils.executeBash(`mv ${join(workspace, filename)} ${pathChecked} && chmod +x ${join(pathChecked, filename)}`);
198
+ else await utils.executeBash(`mv ${join(workspace, filename)} ${pathChecked} && chmod +x ${join(pathChecked, filename)}`);
199
+ }
200
+ if (process.platform === "darwin") {
201
+ const paths = [join(process.env.HOME, "bin"), join(process.env.HOME, ".bin"), join(process.env.HOME, ".local", "bin"), "/usr/local/bin"];
202
+ let pathChecked = "";
203
+ for (const path of paths) {
204
+ if (process.env.PATH.includes(`${path}:`) || process.env.PATH.includes(`:${path}`) || process.env.PATH === `${path}`) {
205
+ pathChecked = path;
206
+ break;
210
207
  }
211
- },
212
- executePowershell: async (script) => {
213
- return execFileSync("powershell.exe", ["-c", script], {
214
- stdio: "inherit",
215
- });
216
- },
217
- executeBash: (script) => {
218
-
219
- return execFileSync("bash", ["-c", `if command -v sudo &>/dev/null; then sudo ${script}; else ${script}; fi`], {
220
- stdio: "inherit",
221
- });
222
- },
223
- };
208
+ }
209
+ if (!pathChecked) {
210
+ consola.error(color("No path found!"));
211
+ exit(0);
212
+ }
213
+ if (!existsSync(pathChecked)) mkdirSync(pathChecked);
214
+ if (existsSync(join(pathChecked, filename))) {
215
+ if (pathChecked.startsWith("/Users")) await utils.executeBash(`rm -f ${join(pathChecked, filename)}`);
216
+ else await utils.executeBash(`rm -f ${join(pathChecked, filename)}`);
217
+ }
218
+ if (pathChecked.startsWith("/Users")) await utils.executeBash(`mv ${join(workspace, filename)} ${pathChecked} && chmod +x ${join(pathChecked, filename)}`);
219
+ else await utils.executeBash(`mv ${join(workspace, filename)} ${pathChecked} && chmod +x ${join(pathChecked, filename)}`);
220
+ }
221
+ },
222
+ executePowershell: async (script) => {
223
+ return execFileSync("powershell.exe", ["-c", script], {
224
+ stdio: "inherit",
225
+ });
226
+ },
227
+ executeBash: (script) => {
228
+ return execFileSync("bash", ["-c", `if command -v sudo &>/dev/null; then sudo ${script}; else ${script}; fi`], {
229
+ stdio: "inherit",
230
+ });
231
+ },
232
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-cookbook",
3
- "version": "1.0.0-beta.5",
3
+ "version": "1.0.0-beta.51",
4
4
  "main": "index.mjs",
5
5
  "bin": {
6
6
  "create-cookbook": "./index.mjs"