create-newt-app 0.25.0 → 0.26.0

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 CHANGED
@@ -1,4 +1,9 @@
1
1
  <div align="center">
2
+ <picture>
3
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/zeevo/newt-app/main/.github/assets/logo-dark.svg">
4
+ <img src="https://raw.githubusercontent.com/zeevo/newt-app/main/.github/assets/logo-light.svg" alt="newt-app" width="120">
5
+ </picture>
6
+
2
7
  <h1>newt-app</h1>
3
8
  <p><strong>Scaffold a production-ready, full-stack TypeScript monorepo in one command.</strong></p>
4
9
 
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ import chalk from "chalk";
7
7
  // package.json
8
8
  var package_default = {
9
9
  name: "create-newt-app",
10
- version: "0.25.0",
10
+ version: "0.26.0",
11
11
  license: "MIT",
12
12
  private: false,
13
13
  type: "module",
@@ -12824,6 +12824,36 @@ function validateDeploymentCombo(deployment, nestDiOnly2) {
12824
12824
  }
12825
12825
  return { valid: true };
12826
12826
  }
12827
+ var TOOL_HINTS = {
12828
+ pnpm: "Install it with `npm install -g pnpm`, or run `corepack enable`.",
12829
+ git: "Install it from https://git-scm.com/downloads, or pass --no-git."
12830
+ };
12831
+ async function checkRequiredTools(needs, hasCommand2) {
12832
+ const required = [
12833
+ ...needs.install ? ["pnpm"] : [],
12834
+ ...needs.git ? ["git"] : []
12835
+ ];
12836
+ const missing = (await Promise.all(
12837
+ required.map(async (tool) => await hasCommand2(tool) ? null : tool)
12838
+ )).filter((tool) => tool !== null);
12839
+ if (missing.length === 0) return { valid: true };
12840
+ return {
12841
+ valid: false,
12842
+ error: missing.map((tool) => `${tool} was not found on PATH. ${TOOL_HINTS[tool]}`).join("\n")
12843
+ };
12844
+ }
12845
+ function validateNodeVersion(current, requirement) {
12846
+ const parse = (value) => (value.match(/\d+/g) ?? []).slice(0, 3).map(Number);
12847
+ const [major = 0, minor = 0, patch = 0] = parse(current);
12848
+ const [minMajor = 0, minMinor = 0, minPatch = 0] = parse(requirement);
12849
+ const satisfied = major !== minMajor ? major > minMajor : minor !== minMinor ? minor > minMinor : patch >= minPatch;
12850
+ if (satisfied) return { valid: true };
12851
+ return {
12852
+ valid: false,
12853
+ error: `Node ${requirement} is required, but this is ${current}.
12854
+ Upgrade Node, or switch versions with a manager such as nvm or fnm.`
12855
+ };
12856
+ }
12827
12857
  function validateProjectName(projectName) {
12828
12858
  if (!projectName) {
12829
12859
  return { valid: false, error: "Project name is required" };
@@ -12877,6 +12907,14 @@ async function scaffold(modules, options) {
12877
12907
  }
12878
12908
  await sortPackageJsons(options.name);
12879
12909
  }
12910
+ async function hasCommand(command) {
12911
+ try {
12912
+ await execa(command, ["--version"]);
12913
+ return true;
12914
+ } catch {
12915
+ return false;
12916
+ }
12917
+ }
12880
12918
  async function pnpmInstall(cwd) {
12881
12919
  return await execa("pnpm", ["install"], {
12882
12920
  cwd
@@ -12977,6 +13015,16 @@ async function doInit(options) {
12977
13015
  }
12978
13016
  };
12979
13017
  try {
13018
+ const preflight = [
13019
+ validateNodeVersion(process.version, package_default.engines.node),
13020
+ await checkRequiredTools(
13021
+ { install: options.install, git: options.git },
13022
+ hasCommand
13023
+ )
13024
+ ].find((result) => !result.valid);
13025
+ if (preflight) {
13026
+ throw new Error(preflight.error);
13027
+ }
12980
13028
  const group2 = await p.group(groupOpts, {
12981
13029
  onCancel: () => {
12982
13030
  console.log("Exiting.");
@@ -13023,11 +13071,7 @@ async function doInit(options) {
13023
13071
  taskBuilder.add({
13024
13072
  title: "Installing with pnpm",
13025
13073
  task: async () => {
13026
- try {
13027
- await pnpmInstall(name);
13028
- } catch (e) {
13029
- console.log(e);
13030
- }
13074
+ await pnpmInstall(name);
13031
13075
  return "Installed.";
13032
13076
  }
13033
13077
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-newt-app",
3
- "version": "0.25.0",
3
+ "version": "0.26.0",
4
4
  "license": "MIT",
5
5
  "private": false,
6
6
  "type": "module",