create-ovok 0.1.0-dev.28 → 0.1.0-dev.33

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.
@@ -1,13 +1,13 @@
1
1
  const REGISTRY = "https://registry.npmjs.org";
2
- /** The version npm installs by default, or null when the registry does not answer in time. */
3
- export async function latestVersion(packageName, signal) {
2
+ /** The version npm serves under `distTag`, or null when the registry does not answer in time. */
3
+ export async function distTagVersion(packageName, distTag, signal) {
4
4
  const url = `${REGISTRY}/-/package/${encodeURIComponent(packageName)}/dist-tags`;
5
5
  try {
6
6
  const response = await fetch(url, { signal });
7
7
  if (!response.ok)
8
8
  return null;
9
- const { latest } = (await response.json());
10
- return typeof latest === "string" ? latest : null;
9
+ const version = (await response.json())[distTag];
10
+ return typeof version === "string" ? version : null;
11
11
  }
12
12
  catch {
13
13
  return null;
@@ -1,4 +1,6 @@
1
1
  const NUMERIC_ORDER = new Intl.Collator("en", { numeric: true });
2
+ const DIST_TAG_BY_CHANNEL = { dev: "dev", rc: "next" };
3
+ const STABLE_DIST_TAG = "latest";
2
4
  /** Semver order: numbers compare as numbers, and a release outranks its own prereleases. */
3
5
  export function isNewer(candidate, current) {
4
6
  const [candidateCore, candidatePrerelease] = splitPrerelease(candidate);
@@ -11,6 +13,12 @@ export function isNewer(candidate, current) {
11
13
  }
12
14
  return NUMERIC_ORDER.compare(candidatePrerelease, currentPrerelease) > 0;
13
15
  }
16
+ /** The npm dist-tag that builds like this one are published under. */
17
+ export function distTagOf(version) {
18
+ const [, prerelease] = splitPrerelease(version);
19
+ const [channel = ""] = prerelease.split(".");
20
+ return DIST_TAG_BY_CHANNEL[channel] ?? STABLE_DIST_TAG;
21
+ }
14
22
  function splitPrerelease(version) {
15
23
  const [withoutBuild = ""] = version.split("+");
16
24
  const dash = withoutBuild.indexOf("-");
package/dist/main.js CHANGED
@@ -4,14 +4,14 @@ import { parseArgs, styleText } from "node:util";
4
4
  import { cancel } from "@clack/prompts";
5
5
  import { ClackPrompt } from "./adapters/clack-prompt.js";
6
6
  import { FsProjectFiles } from "./adapters/fs-project-files.js";
7
- import { latestVersion } from "./adapters/npm-registry.js";
7
+ import { distTagVersion } from "./adapters/npm-registry.js";
8
8
  import { dependenciesAt } from "./adapters/scaffold-dependencies.js";
9
9
  import { addApp, addPackage } from "./application/add-app.js";
10
10
  import { refreshAgentRules } from "./application/refresh-agent-rules.js";
11
11
  import { CancelledError, DEFAULT_ANSWERS, RECOMMENDED, } from "./application/workspace-answers.js";
12
12
  import { initialiseGit, install, scaffold, showNextSteps } from "./commands/create.js";
13
13
  import { MOBILE_OSES, osFor, PLATFORMS, parseChoice, parsePackageName, STARTING_PLATFORMS, } from "./domain/app-spec.js";
14
- import { isNewer } from "./domain/version.js";
14
+ import { distTagOf, isNewer } from "./domain/version.js";
15
15
  const EXIT_FAILURE = 1;
16
16
  const EXIT_CANCELLED = 130;
17
17
  const UPDATE_CHECK_TIMEOUT_MS = 1_500;
@@ -97,12 +97,13 @@ async function create(name, values) {
97
97
  async function updateNotice({ name, version }) {
98
98
  if (!process.stderr.isTTY)
99
99
  return null;
100
- const latest = await latestVersion(name, AbortSignal.timeout(UPDATE_CHECK_TIMEOUT_MS));
101
- return latest !== null && isNewer(latest, version) ? updateMessage(version, latest) : null;
100
+ const signal = AbortSignal.timeout(UPDATE_CHECK_TIMEOUT_MS);
101
+ const newest = await distTagVersion(name, distTagOf(version), signal);
102
+ return newest !== null && isNewer(newest, version) ? updateMessage(version, newest) : null;
102
103
  }
103
- function updateMessage(current, latest) {
104
- const update = styleText("cyan", `pnpm create ovok@${latest}`);
105
- return `${styleText("yellow", "Update available:")} ${current} → ${latest}. Next time run ${update}`;
104
+ function updateMessage(current, newest) {
105
+ const update = styleText("cyan", `pnpm create ovok@${newest}`);
106
+ return `${styleText("yellow", "Update available:")} ${current} → ${newest}. Next time run ${update}`;
106
107
  }
107
108
  function promptFor(values) {
108
109
  const interactive = process.stdin.isTTY && process.stdout.isTTY && !values.yes;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-ovok",
3
- "version": "0.1.0-dev.28",
3
+ "version": "0.1.0-dev.33+5f9fdd8",
4
4
  "description": "Create a Turborepo with Ovok web and mobile apps, and add more apps through turbo gen.",
5
5
  "license": "MIT",
6
6
  "type": "module",