@create-node-app/core 0.2.5 → 0.3.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/dist/index.d.ts CHANGED
@@ -3,6 +3,7 @@ type TemplateOrExtension = {
3
3
  ignorePackage?: boolean;
4
4
  };
5
5
 
6
+ declare const checkNodeVersion: (requiredVersion: string, packageName: string) => void;
6
7
  declare const checkForLatestVersion: (packageName: string) => Promise<string | null>;
7
8
  declare const printEnvInfo: () => Promise<never>;
8
9
  type CnaOptions = {
@@ -35,4 +36,4 @@ type CnaOptionsTransform = (options: CnaOptions) => Promise<CnaOptions>;
35
36
  */
36
37
  declare const createNodeApp: (programName: string, options: CnaOptions, transformOptions: CnaOptionsTransform) => Promise<void>;
37
38
 
38
- export { CnaOptions, CnaOptionsTransform, checkForLatestVersion, createNodeApp, printEnvInfo };
39
+ export { CnaOptions, CnaOptionsTransform, checkForLatestVersion, checkNodeVersion, createNodeApp, printEnvInfo };
package/dist/index.js CHANGED
@@ -31,12 +31,14 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
31
31
  var create_node_app_core_exports = {};
32
32
  __export(create_node_app_core_exports, {
33
33
  checkForLatestVersion: () => checkForLatestVersion,
34
+ checkNodeVersion: () => checkNodeVersion,
34
35
  createNodeApp: () => createNodeApp,
35
36
  printEnvInfo: () => printEnvInfo
36
37
  });
37
38
  module.exports = __toCommonJS(create_node_app_core_exports);
38
39
  var import_chalk4 = __toESM(require("chalk"));
39
40
  var import_envinfo = __toESM(require("envinfo"));
41
+ var import_semver3 = __toESM(require("semver"));
40
42
  var import_child_process4 = require("child_process");
41
43
 
42
44
  // installer.ts
@@ -261,6 +263,7 @@ var clone = (git, target, branch) => {
261
263
  var pull = async (cwd) => {
262
264
  await exec("git checkout -f", { cwd });
263
265
  await exec("git pull", { cwd });
266
+ await new Promise((resolve) => setTimeout(resolve, 400));
264
267
  };
265
268
  var downloadRepository = async ({
266
269
  url = "",
@@ -290,13 +293,11 @@ var downloadRepository = async ({
290
293
  return;
291
294
  }
292
295
  await pull(cacheDir);
293
- setTimeout(() => {
294
- import_fs.default.cpSync(cacheDir, absoluteTarget, {
295
- force: true,
296
- filter: filterGit,
297
- recursive: true
298
- });
299
- }, 400);
296
+ import_fs.default.cpSync(cacheDir, absoluteTarget, {
297
+ force: true,
298
+ filter: filterGit,
299
+ recursive: true
300
+ });
300
301
  };
301
302
 
302
303
  // paths.ts
@@ -457,7 +458,10 @@ var loadPackages = async ({
457
458
  scripts: {}
458
459
  })
459
460
  );
460
- return getInstallableSetup(setup);
461
+ return getInstallableSetup({
462
+ ...setup,
463
+ name: config.appName
464
+ });
461
465
  };
462
466
 
463
467
  // loaders.ts
@@ -939,6 +943,18 @@ Please update to npm 3 or higher for a better, fully supported experience.
939
943
  };
940
944
 
941
945
  // index.ts
946
+ var checkNodeVersion = (requiredVersion, packageName) => {
947
+ if (!import_semver3.default.satisfies(process.version, requiredVersion)) {
948
+ console.error(
949
+ import_chalk4.default.red(
950
+ `You are running Node ${process.version}.
951
+ ${packageName} requires Node ${requiredVersion}.
952
+ Please update your version of Node.`
953
+ )
954
+ );
955
+ process.exit(1);
956
+ }
957
+ };
942
958
  var checkForLatestVersion = async (packageName) => {
943
959
  try {
944
960
  const response = await fetch(
@@ -1001,6 +1017,7 @@ var createNodeApp = async (programName, options, transformOptions) => {
1001
1017
  // Annotate the CommonJS export names for ESM import in node:
1002
1018
  0 && (module.exports = {
1003
1019
  checkForLatestVersion,
1020
+ checkNodeVersion,
1004
1021
  createNodeApp,
1005
1022
  printEnvInfo
1006
1023
  });
package/dist/index.mjs CHANGED
@@ -9,6 +9,7 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
9
9
  // index.ts
10
10
  import chalk4 from "chalk";
11
11
  import envinfo from "envinfo";
12
+ import semver3 from "semver";
12
13
  import { execSync as execSync3 } from "child_process";
13
14
 
14
15
  // installer.ts
@@ -233,6 +234,7 @@ var clone = (git, target, branch) => {
233
234
  var pull = async (cwd) => {
234
235
  await exec("git checkout -f", { cwd });
235
236
  await exec("git pull", { cwd });
237
+ await new Promise((resolve) => setTimeout(resolve, 400));
236
238
  };
237
239
  var downloadRepository = async ({
238
240
  url = "",
@@ -262,13 +264,11 @@ var downloadRepository = async ({
262
264
  return;
263
265
  }
264
266
  await pull(cacheDir);
265
- setTimeout(() => {
266
- fs.cpSync(cacheDir, absoluteTarget, {
267
- force: true,
268
- filter: filterGit,
269
- recursive: true
270
- });
271
- }, 400);
267
+ fs.cpSync(cacheDir, absoluteTarget, {
268
+ force: true,
269
+ filter: filterGit,
270
+ recursive: true
271
+ });
272
272
  };
273
273
 
274
274
  // paths.ts
@@ -429,7 +429,10 @@ var loadPackages = async ({
429
429
  scripts: {}
430
430
  })
431
431
  );
432
- return getInstallableSetup(setup);
432
+ return getInstallableSetup({
433
+ ...setup,
434
+ name: config.appName
435
+ });
433
436
  };
434
437
 
435
438
  // loaders.ts
@@ -911,6 +914,18 @@ Please update to npm 3 or higher for a better, fully supported experience.
911
914
  };
912
915
 
913
916
  // index.ts
917
+ var checkNodeVersion = (requiredVersion, packageName) => {
918
+ if (!semver3.satisfies(process.version, requiredVersion)) {
919
+ console.error(
920
+ chalk4.red(
921
+ `You are running Node ${process.version}.
922
+ ${packageName} requires Node ${requiredVersion}.
923
+ Please update your version of Node.`
924
+ )
925
+ );
926
+ process.exit(1);
927
+ }
928
+ };
914
929
  var checkForLatestVersion = async (packageName) => {
915
930
  try {
916
931
  const response = await fetch(
@@ -972,6 +987,7 @@ var createNodeApp = async (programName, options, transformOptions) => {
972
987
  };
973
988
  export {
974
989
  checkForLatestVersion,
990
+ checkNodeVersion,
975
991
  createNodeApp,
976
992
  printEnvInfo
977
993
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@create-node-app/core",
3
- "version": "0.2.5",
3
+ "version": "0.3.0",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",