create-newt-app 0.35.2 → 0.35.4

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/dist/index.js CHANGED
@@ -7,11 +7,11 @@ import { fileURLToPath } from "node:url";
7
7
  import { randomBytes } from "node:crypto";
8
8
  import { execa } from "execa";
9
9
  import ejs from "ejs";
10
- import { existsSync, promises } from "fs";
10
+ import { existsSync, promises, readdirSync } from "fs";
11
11
  import path from "path";
12
12
  import https from "node:https";
13
13
  //#region package.json
14
- var version = "0.35.2";
14
+ var version = "0.35.4";
15
15
  var engines = { "node": ">=24.0.0" };
16
16
  //#endregion
17
17
  //#region src/templates/root/index.ts
@@ -10209,6 +10209,8 @@ const config = {
10209
10209
  "@stylexjs/postcss-plugin": {
10210
10210
  include: [
10211
10211
  "app/**/*.{js,jsx,ts,tsx}",
10212
+ "components/**/*.{js,jsx,ts,tsx}",
10213
+ "lib/**/*.{js,jsx,ts,tsx}",
10212
10214
  "../../packages/ui/src/**/*.{js,jsx,ts,tsx}",
10213
10215
  ],
10214
10216
  babelConfig: {
@@ -11604,7 +11606,7 @@ describe('AppController (e2e)', () => {
11604
11606
  {
11605
11607
  module: "apps/api",
11606
11608
  name: "test:debug",
11607
- script: "vitest --inspect-brk --inspect --logHeapUsage --threads=false"
11609
+ script: "vitest --inspect-brk --no-file-parallelism"
11608
11610
  },
11609
11611
  {
11610
11612
  module: "apps/api",
@@ -11784,6 +11786,7 @@ export default nextConfig;`
11784
11786
  "dependsOn": ["^build"]
11785
11787
  },
11786
11788
  "dev": {
11789
+ "dependsOn": ["^migrate"],
11787
11790
  "env": ["DATABASE_URL"],
11788
11791
  "cache": false,
11789
11792
  "persistent": true
@@ -11811,6 +11814,7 @@ const singleProcessStaticExport = { templates: [{
11811
11814
  "private": true,
11812
11815
  "scripts": {
11813
11816
  "build": "nest build",
11817
+ "typecheck": "tsc -p tsconfig.build.json --noEmit",
11814
11818
  "start": "nest start",
11815
11819
  "dev": "nest start --watch",
11816
11820
  "start:debug": "nest start --debug --watch",
@@ -11882,7 +11886,8 @@ const nestDiOnly = { templates: [
11882
11886
  ".": "./src/index.ts"
11883
11887
  },
11884
11888
  "scripts": {
11885
- "build": "nest build"
11889
+ "build": "nest build",
11890
+ "typecheck": "tsc -p tsconfig.build.json --noEmit"
11886
11891
  },
11887
11892
  "dependencies": {
11888
11893
  "@nestjs/common": "<%= versions["@nestjs/common"] %>",
@@ -13899,27 +13904,41 @@ function validateNodeVersion(current, requirement) {
13899
13904
  function normalizeProjectName(projectName) {
13900
13905
  return projectName.trim().normalize("NFKD").replace(/[\u0300-\u036f]/g, "").toLowerCase().replace(/\s+/g, "-").replace(/[^a-z0-9\-._~]/g, "-").replace(/-+/g, "-").replace(/^[-._]+/, "").replace(/-+$/, "").slice(0, 214);
13901
13906
  }
13907
+ function projectTarget(projectName) {
13908
+ if ([".", "./"].includes(projectName.trim())) return {
13909
+ name: normalizeProjectName(path.basename(process.cwd())),
13910
+ dir: "."
13911
+ };
13912
+ const name = normalizeProjectName(projectName);
13913
+ return {
13914
+ name,
13915
+ dir: name
13916
+ };
13917
+ }
13902
13918
  function validateProjectName(projectName) {
13903
13919
  if (!projectName) return {
13904
13920
  valid: false,
13905
13921
  error: "Project name is required"
13906
13922
  };
13907
- const normalized = normalizeProjectName(projectName);
13908
- if (!normalized) return {
13923
+ const { name, dir } = projectTarget(projectName);
13924
+ if (!name) return {
13909
13925
  valid: false,
13910
13926
  error: `"${projectName}" has nothing left after normalizing. Include a letter or a digit.`
13911
13927
  };
13912
- const targetPath = path.resolve(process.cwd(), normalized);
13913
- if (existsSync(targetPath)) return {
13928
+ if (dir === ".") return readdirSync(process.cwd()).length === 0 ? { valid: true } : {
13929
+ valid: false,
13930
+ error: "The current directory is not empty"
13931
+ };
13932
+ if (existsSync(path.resolve(process.cwd(), dir))) return {
13914
13933
  valid: false,
13915
- error: `Directory "${normalized}" already exists`
13934
+ error: `Directory "${dir}" already exists`
13916
13935
  };
13917
13936
  return { valid: true };
13918
13937
  }
13919
13938
  //#endregion
13920
13939
  //#region src/tasks.ts
13921
13940
  async function scaffold(modules, options) {
13922
- const validation = validateProjectName(options.name);
13941
+ const validation = validateProjectName(options.dir);
13923
13942
  if (!validation.valid) {
13924
13943
  console.error(`Error: ${validation.error}`);
13925
13944
  process.exit(1);
@@ -13936,12 +13955,12 @@ async function scaffold(modules, options) {
13936
13955
  authSecret: randomBytes(32).toString("base64url"),
13937
13956
  versions
13938
13957
  };
13939
- await renderTemplatesToDisk(modules, options.name, templateData, options.selection);
13958
+ await renderTemplatesToDisk(modules, options.dir, templateData, options.selection);
13940
13959
  const packages = modules.map((mod) => mod.packages).filter((ele) => ele !== void 0).flat();
13941
- if (packages.length > 0) await updatePackageJson(options.name, packages, templateData);
13960
+ if (packages.length > 0) await updatePackageJson(options.dir, packages, templateData);
13942
13961
  const scripts = modules.map((mod) => mod.scripts).filter((ele) => ele !== void 0).flat();
13943
- if (scripts.length > 0) await updateScripts(options.name, scripts, templateData);
13944
- await sortPackageJsons(options.name);
13962
+ if (scripts.length > 0) await updateScripts(options.dir, scripts, templateData);
13963
+ await sortPackageJsons(options.dir);
13945
13964
  }
13946
13965
  async function hasCommand(command) {
13947
13966
  try {
@@ -14229,13 +14248,14 @@ async function doInit(options) {
14229
14248
  const rawName = answers.name ?? options.name ?? "";
14230
14249
  const nameCheck = validateProjectName(rawName);
14231
14250
  if (!nameCheck.valid) throw new Error(nameCheck.error);
14232
- const name = normalizeProjectName(rawName);
14251
+ const { name, dir } = projectTarget(rawName);
14233
14252
  const taskBuilder = new TaskBuilder();
14234
14253
  taskBuilder.add({
14235
14254
  title: "Scaffolding project",
14236
14255
  task: async () => {
14237
14256
  await scaffold(allModules, {
14238
14257
  name,
14258
+ dir,
14239
14259
  testing,
14240
14260
  database,
14241
14261
  deployment,
@@ -14250,14 +14270,14 @@ async function doInit(options) {
14250
14270
  taskBuilder.add({
14251
14271
  title: "Installing with pnpm",
14252
14272
  task: async () => {
14253
- await pnpmInstall(name);
14273
+ await pnpmInstall(dir);
14254
14274
  return "Installed.";
14255
14275
  }
14256
14276
  });
14257
14277
  taskBuilder.add({
14258
14278
  title: "Formatting",
14259
14279
  task: async () => {
14260
- await pnpmFormat(name);
14280
+ await pnpmFormat(dir);
14261
14281
  return "Formatted.";
14262
14282
  }
14263
14283
  });
@@ -14266,19 +14286,19 @@ async function doInit(options) {
14266
14286
  if (options.git) taskBuilder.add({
14267
14287
  title: "Initializing git",
14268
14288
  task: async () => {
14269
- committed = await initGit(name);
14289
+ committed = await initGit(dir);
14270
14290
  return committed ? "Initialized git." : "Initialized git, but could not commit.";
14271
14291
  }
14272
14292
  });
14273
14293
  await p.tasks(taskBuilder.tasks);
14274
14294
  p.outro(`Done!`);
14275
- if (name !== rawName) {
14276
- console.log(`Note: the project directory is "${name}", not "${rawName}".`);
14295
+ if (dir !== "." && dir !== rawName) {
14296
+ console.log(`Note: the project directory is "${dir}", not "${rawName}".`);
14277
14297
  console.log();
14278
14298
  }
14279
14299
  console.log("Next steps:");
14280
14300
  console.log();
14281
- console.log(chalk.blue(` cd ${name}`));
14301
+ if (dir !== ".") console.log(chalk.blue(` cd ${dir}`));
14282
14302
  if (!options.install) {
14283
14303
  console.log(chalk.blue(` pnpm install`));
14284
14304
  console.log(chalk.blue(` pnpm format:fix`));