message: feat(create): retry 3 times when getting version
diff: import { get } from "https";
  -export const checkForNextVersion = (
  +export const checkForNextVersion = async (
  packageName: string,
  bin: "npm" | "yarn"
  -): Promise<string> =>
  +): Promise<string> => {
  + const getVersionInfo = (): Promise<string> =>
  new Promise((resolve, reject) => {
  get(
  `${
  @@ -21,18 +22,21 @@ export const checkForNextVersion = (
  resolve(JSON.parse(body).next as string);
  });
  } else {
  - reject(
  - new Error(
  - `Get ${packageName} version failed, please check your network!`
  - )
  - );
  + reject();
  }
  }
  ).on("error", () => {
  - reject(
  - new Error(
  - `Get ${packageName} version failed, please check your network!`
  - )
  - );
  + reject();
  });
  });
  +
  + for (let times = 1; times <= 3; times++) {
  + const version = await getVersionInfo().catch(() => {
  + console.log(`Get ${packageName} version failed, [${times}/3]`);
  + });
  +
  + if (version) return version;
  + }
  +
  + throw new Error(`Get ${packageName} version failed!`);
  +};
  