create-video 4.0.380 → 4.0.382

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.
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.resolveProjectRoot = void 0;
7
7
  const chalk_1 = __importDefault(require("chalk"));
8
8
  const node_fs_1 = __importDefault(require("node:fs"));
9
+ const promises_1 = require("node:fs/promises");
9
10
  const node_os_1 = require("node:os");
10
11
  const node_path_1 = __importDefault(require("node:path"));
11
12
  const log_1 = require("./log");
@@ -41,6 +42,7 @@ const resolveProjectRoot = async (options) => {
41
42
  return { projectRoot: randomRoot, folderName: randomName };
42
43
  }
43
44
  let projectName = '';
45
+ let directlyCreateInCurrentDir = false;
44
46
  // If a directory argument was provided, use it directly
45
47
  if (options === null || options === void 0 ? void 0 : options.directoryArgument) {
46
48
  projectName = options.directoryArgument;
@@ -52,21 +54,35 @@ const resolveProjectRoot = async (options) => {
52
54
  log_1.Log.info();
53
55
  }
54
56
  try {
55
- const { answer } = await (0, prompts_1.default)({
56
- type: 'text',
57
- name: 'answer',
58
- message: 'Directory to create your project',
59
- initial: 'my-video',
60
- validate: (name) => {
61
- const validation = (0, validate_name_1.validateName)(node_path_1.default.basename(node_path_1.default.resolve(name)));
62
- if (typeof validation === 'string') {
63
- return 'Invalid project name: ' + validation;
64
- }
65
- return true;
66
- },
67
- });
68
- if (typeof answer === 'string') {
69
- projectName = answer.trim();
57
+ const currentMs = Date.now();
58
+ const hour = 60 * 60 * 1000;
59
+ const dirCreateMs = (await (0, promises_1.stat)(process.cwd())).ctimeMs;
60
+ const fileList = await (0, promises_1.readdir)(process.cwd());
61
+ const fileCount = fileList.filter((f) => !f.startsWith('.')).length;
62
+ if (fileCount === 0 && currentMs - dirCreateMs < hour) {
63
+ // User seems to have created a new directory which is empty, and cd'd into it. Let's create the project here!
64
+ directlyCreateInCurrentDir = true;
65
+ }
66
+ if (directlyCreateInCurrentDir) {
67
+ projectName = process.cwd();
68
+ }
69
+ else {
70
+ const { answer } = await (0, prompts_1.default)({
71
+ type: 'text',
72
+ name: 'answer',
73
+ message: 'Directory to create your project',
74
+ initial: 'my-video',
75
+ validate: (name) => {
76
+ const validation = (0, validate_name_1.validateName)(node_path_1.default.basename(node_path_1.default.resolve(name)));
77
+ if (typeof validation === 'string') {
78
+ return 'Invalid project name: ' + validation;
79
+ }
80
+ return true;
81
+ },
82
+ });
83
+ if (typeof answer === 'string') {
84
+ projectName = answer.trim();
85
+ }
70
86
  }
71
87
  }
72
88
  catch (error) {
@@ -78,8 +94,11 @@ const resolveProjectRoot = async (options) => {
78
94
  }
79
95
  const projectRoot = node_path_1.default.resolve(projectName);
80
96
  const folderName = node_path_1.default.basename(projectRoot);
81
- assertValidName(folderName);
82
- (0, mkdirp_1.mkdirp)(projectRoot);
97
+ if (!directlyCreateInCurrentDir) {
98
+ // if a folder is already created, no point of checking if it's valid
99
+ assertValidName(folderName);
100
+ (0, mkdirp_1.mkdirp)(projectRoot);
101
+ }
83
102
  if (assertFolderEmptyAsync(projectRoot).exists) {
84
103
  return (0, exports.resolveProjectRoot)(options);
85
104
  }
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "url": "https://github.com/remotion-dev/remotion/tree/main/packages/create-video"
4
4
  },
5
5
  "name": "create-video",
6
- "version": "4.0.380",
6
+ "version": "4.0.382",
7
7
  "description": "Create a new Remotion project",
8
8
  "main": "dist/index.js",
9
9
  "bin": {
@@ -28,8 +28,8 @@
28
28
  "@types/minimist": "1.2.2",
29
29
  "@types/prompts": "^2.0.12",
30
30
  "@types/tar": "6.1.1",
31
- "react": "19.0.0",
32
- "@remotion/eslint-config-internal": "4.0.380",
31
+ "react": "19.2.1",
32
+ "@remotion/eslint-config-internal": "4.0.382",
33
33
  "eslint": "9.19.0"
34
34
  },
35
35
  "exports": {