create-cookbook 1.0.0-alpha.94 → 1.0.0-alpha.95

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 +18 -15
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -18,22 +18,23 @@ const color = gradient(["cyan", "#2d9b87"]);
18
18
  (async () => {
19
19
  const args = process.argv.slice(2);
20
20
  let version = "latest";
21
+ // biome-ignore lint/complexity/useOptionalChain: <explanation>
21
22
  if (args[0] && args[0].startsWith("--version=")) {
22
23
  version = args[0].slice(10);
23
24
  }
24
- let workspace = process.platform === "win32" ? join(process.env.USERPROFILE, ".cookbook") : join(process.env.HOME, ".cookbook");
25
- let tempspace = process.platform === "win32" ? join(process.env.USERPROFILE, ".cookbook", ".temp") : join(process.env.HOME, ".cookbook", ".temp");
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");
26
27
  if (!existsSync(workspace)) mkdirSync(workspace);
27
28
  if (!existsSync(tempspace)) mkdirSync(tempspace);
28
29
 
29
- const uiName = `@milkio/cookbook-ui`;
30
+ const uiName = "@milkio/cookbook-ui";
30
31
  const cookbookName = `@milkio/cookbook-${process.platform}-${os.arch()}`;
31
32
  let uiPackageInfo;
32
33
  let cookbookPackageInfo;
33
34
  console.log("");
34
35
  for (const mirror of ["https://registry.npmjs.org/", "https://registry.npmmirror.com/", "https://mirrors.cloud.tencent.com/npm/", "https://cdn.jsdelivr.net/npm/"]) {
35
36
  try {
36
- consola.start(color(`Checking (${mirror}${uiName})..`));
37
+ consola.start(color(`[1/2] Checking (${mirror}${uiName})..`));
37
38
  const controller = new AbortController();
38
39
  const timeout = setTimeout(() => controller.abort(), 8000);
39
40
  const response = await fetch(`${mirror}${uiName}`, {
@@ -49,6 +50,7 @@ const color = gradient(["cyan", "#2d9b87"]);
49
50
  };
50
51
  break;
51
52
  } catch (error) {
53
+ // biome-ignore lint/correctness/noUnnecessaryContinue: <explanation>
52
54
  continue;
53
55
  }
54
56
  }
@@ -58,7 +60,7 @@ const color = gradient(["cyan", "#2d9b87"]);
58
60
  }
59
61
  for (const mirror of ["https://registry.npmjs.org/", "https://registry.npmmirror.com/", "https://mirrors.cloud.tencent.com/npm/", "https://cdn.jsdelivr.net/npm/"]) {
60
62
  try {
61
- consola.start(color(`Checking (${mirror}${cookbookName})..`));
63
+ consola.start(color(`[2/2] Checking (${mirror}${cookbookName})..`));
62
64
  const controller = new AbortController();
63
65
  const timeout = setTimeout(() => controller.abort(), 8000);
64
66
  const response = await fetch(`${mirror}${cookbookName}`, {
@@ -74,6 +76,7 @@ const color = gradient(["cyan", "#2d9b87"]);
74
76
  };
75
77
  break;
76
78
  } catch (error) {
79
+ // biome-ignore lint/correctness/noUnnecessaryContinue: <explanation>
77
80
  continue;
78
81
  }
79
82
  }
@@ -84,9 +87,9 @@ const color = gradient(["cyan", "#2d9b87"]);
84
87
 
85
88
  const uiUrl = `${cookbookPackageInfo.mirror}${uiName}/-/cookbook-ui-${version === 'latest' ? uiPackageInfo.json["dist-tags"].latest : version}.tgz`;
86
89
  consola.start(uiUrl);
87
- consola.start(color(`Downloading Cookbook UI (${uiUrl})..`));
90
+ consola.start(color(`[1/2] Downloading Cookbook UI (${uiUrl})..`));
88
91
  await utils.downloadFile(uiUrl, tempspace, "ui.tgz");
89
- consola.success(color("Downloaded!"));
92
+ consola.success(color("[1/2] Downloaded!"));
90
93
  const uiExtractPromise = ((async () => {
91
94
  if (!existsSync(join(tempspace, "ui"))) mkdirSync(join(tempspace, "ui"))
92
95
  await compressing.tgz.uncompress(join(tempspace, "ui.tgz"), join(tempspace, "ui"));
@@ -94,26 +97,26 @@ const color = gradient(["cyan", "#2d9b87"]);
94
97
 
95
98
  const cookbookUrl = `${cookbookPackageInfo.mirror}${cookbookName}/-/cookbook-${process.platform}-${os.arch()}-${version === 'latest' ? cookbookPackageInfo.json["dist-tags"].latest : version}.tgz`;
96
99
  consola.start(cookbookUrl);
97
- consola.start(color(`Downloading Cookbook Core (${cookbookUrl})..`));
100
+ consola.start(color(`[2/2] Downloading Cookbook Core (${cookbookUrl})..`));
98
101
  await utils.downloadFile(cookbookUrl, tempspace, "cookbook.tgz");
99
- consola.success(color("Downloaded!"));
102
+ consola.success(color("[2/2] Downloaded!"));
100
103
  const cookbookExtractPromise = ((async () => {
101
104
  await compressing.tgz.uncompress(join(tempspace, "cookbook.tgz"), tempspace);
102
105
  }))();
103
106
 
104
- consola.start(color(`Extracting..`));
107
+ consola.start(color("[1/2] Extracting.."));
105
108
  await Promise.all([uiExtractPromise, cookbookExtractPromise]);
106
- consola.success(color("Extracted!"));
109
+ consola.success(color("[1/2] Extracted!"));
107
110
 
108
- consola.success(color("Installing.."));
111
+ consola.success(color("[2/2] Installing.."));
109
112
  await utils.mvToPathAndInstall(join(tempspace, "package"), process.platform === "win32" ? "co.exe" : "co", tempspace);
110
113
  await utils.mvUIDir(join(tempspace, "ui", "package"));
111
114
  await utils.tempspaceClean(tempspace);
112
- consola.success(color("Installed!"));
115
+ consola.success(color("[2/2] Installed!"));
113
116
 
114
117
  console.log("");
115
- consola.info(color(`Try run: co version`));
116
- consola.info(colorLong(`* If you find that the co command does not exist, try restarting your Terminal or System`));
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"));
117
120
  })();
118
121
 
119
122
  const utils = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-cookbook",
3
- "version": "1.0.0-alpha.94",
3
+ "version": "1.0.0-alpha.95",
4
4
  "main": "index.mjs",
5
5
  "bin": {
6
6
  "create-cookbook": "./index.mjs"